@@ -440,7 +440,7 @@ zend_result php_openssl_load_rand_file(const char * file, int *egdsocket, int *s
440440 return SUCCESS ;
441441#endif
442442 }
443- if (file == NULL || ! RAND_load_file (file , -1 )) {
443+ if (file == NULL || RAND_load_file (file , -1 ) < 0 ) {
444444 if (RAND_status () == 0 ) {
445445 php_openssl_store_errors ();
446446 php_error_docref (NULL , E_WARNING , "Unable to load random state; not enough random data!" );
@@ -465,7 +465,7 @@ zend_result php_openssl_write_rand_file(const char * file, int egdsocket, int se
465465 if (file == NULL ) {
466466 file = RAND_file_name (buffer , sizeof (buffer ));
467467 }
468- if (file == NULL || ! RAND_write_file (file )) {
468+ if (file == NULL || RAND_write_file (file ) < 0 ) {
469469 php_openssl_store_errors ();
470470 php_error_docref (NULL , E_WARNING , "Unable to write random state" );
471471 return FAILURE ;
@@ -1671,7 +1671,7 @@ zend_result php_openssl_validate_iv(const char **piv, size_t *piv_len, size_t iv
16711671 char * iv_new ;
16721672
16731673 if (mode -> is_aead ) {
1674- if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_ivlen_flag , * piv_len , NULL ) != 1 ) {
1674+ if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_ivlen_flag , * piv_len , NULL ) <= 0 ) {
16751675 php_error_docref (NULL , E_WARNING , "Setting of IV length for AEAD mode failed" );
16761676 return FAILURE ;
16771677 }
@@ -1742,15 +1742,15 @@ zend_result php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
17421742 return FAILURE ;
17431743 }
17441744 if (mode -> set_tag_length_always || (enc && mode -> set_tag_length_when_encrypting )) {
1745- if (! EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_set_tag_flag , tag_len , NULL )) {
1745+ if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_set_tag_flag , tag_len , NULL ) <= 0 ) {
17461746 php_error_docref (NULL , E_WARNING , "Setting tag length for AEAD cipher failed" );
17471747 return FAILURE ;
17481748 }
17491749 }
17501750 if (!enc && tag && tag_len > 0 ) {
17511751 if (!mode -> is_aead ) {
17521752 php_error_docref (NULL , E_WARNING , "The tag cannot be used because the cipher algorithm does not support AEAD" );
1753- } else if (! EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_set_tag_flag , tag_len , (unsigned char * ) tag )) {
1753+ } else if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_set_tag_flag , tag_len , (unsigned char * ) tag ) <= 0 ) {
17541754 php_error_docref (NULL , E_WARNING , "Setting tag for AEAD cipher decryption failed" );
17551755 return FAILURE ;
17561756 }
@@ -1886,7 +1886,7 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt(
18861886 if (mode .is_aead && tag ) {
18871887 zend_string * tag_str = zend_string_alloc (tag_len , 0 );
18881888
1889- if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode .aead_get_tag_flag , tag_len , ZSTR_VAL (tag_str )) == 1 ) {
1889+ if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode .aead_get_tag_flag , tag_len , ZSTR_VAL (tag_str )) > 0 ) {
18901890 ZSTR_VAL (tag_str )[tag_len ] = '\0' ;
18911891 ZSTR_LEN (tag_str ) = tag_len ;
18921892 ZEND_TRY_ASSIGN_REF_NEW_STR (tag , tag_str );
0 commit comments