@@ -4865,6 +4865,7 @@ PHP_FUNCTION(openssl_seal)
4865
4865
4866
4866
if (!EVP_EncryptInit (& ctx ,cipher ,NULL ,NULL )) {
4867
4867
RETVAL_FALSE ;
4868
+ EVP_CIPHER_CTX_cleanup (& ctx );
4868
4869
goto clean_exit ;
4869
4870
}
4870
4871
@@ -4875,10 +4876,12 @@ PHP_FUNCTION(openssl_seal)
4875
4876
#endif
4876
4877
/* allocate one byte extra to make room for \0 */
4877
4878
buf = emalloc (data_len + EVP_CIPHER_CTX_block_size (& ctx ));
4879
+ EVP_CIPHER_CTX_cleanup (& ctx );
4878
4880
4879
4881
if (!EVP_SealInit (& ctx , cipher , eks , eksl , NULL , pkeys , nkeys ) || !EVP_SealUpdate (& ctx , buf , & len1 , (unsigned char * )data , data_len )) {
4880
4882
RETVAL_FALSE ;
4881
4883
efree (buf );
4884
+ EVP_CIPHER_CTX_cleanup (& ctx );
4882
4885
goto clean_exit ;
4883
4886
}
4884
4887
@@ -4911,6 +4914,7 @@ PHP_FUNCTION(openssl_seal)
4911
4914
efree (buf );
4912
4915
}
4913
4916
RETVAL_LONG (len1 + len2 );
4917
+ EVP_CIPHER_CTX_cleanup (& ctx );
4914
4918
4915
4919
clean_exit :
4916
4920
for (i = 0 ; i < nkeys ; i ++ ) {
@@ -4969,25 +4973,21 @@ PHP_FUNCTION(openssl_open)
4969
4973
if (EVP_OpenInit (& ctx , cipher , (unsigned char * )ekey , ekey_len , NULL , pkey ) && EVP_OpenUpdate (& ctx , buf , & len1 , (unsigned char * )data , data_len )) {
4970
4974
if (!EVP_OpenFinal (& ctx , buf + len1 , & len2 ) || (len1 + len2 == 0 )) {
4971
4975
efree (buf );
4972
- if (keyresource == -1 ) {
4973
- EVP_PKEY_free (pkey );
4974
- }
4975
- RETURN_FALSE ;
4976
+ RETVAL_FALSE ;
4977
+ } else {
4978
+ zval_dtor (opendata );
4979
+ buf [len1 + len2 ] = '\0' ;
4980
+ ZVAL_STRINGL (opendata , erealloc (buf , len1 + len2 + 1 ), len1 + len2 , 0 );
4981
+ RETVAL_TRUE ;
4976
4982
}
4977
4983
} else {
4978
4984
efree (buf );
4979
- if (keyresource == -1 ) {
4980
- EVP_PKEY_free (pkey );
4981
- }
4982
- RETURN_FALSE ;
4985
+ RETVAL_FALSE ;
4983
4986
}
4984
4987
if (keyresource == -1 ) {
4985
4988
EVP_PKEY_free (pkey );
4986
4989
}
4987
- zval_dtor (opendata );
4988
- buf [len1 + len2 ] = '\0' ;
4989
- ZVAL_STRINGL (opendata , erealloc (buf , len1 + len2 + 1 ), len1 + len2 , 0 );
4990
- RETURN_TRUE ;
4990
+ EVP_CIPHER_CTX_cleanup (& ctx );
4991
4991
}
4992
4992
/* }}} */
4993
4993
0 commit comments