Skip to content

Commit 0f731b4

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix error return check of EVP_CIPHER_CTX_ctrl() Fix memleak on failure in collator_get_sort_key()
2 parents f938f35 + cd87223 commit 0f731b4

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.4.12
44

5+
- Intl:
6+
. Fix memleak on failure in collator_get_sort_key(). (nielsdos)
7+
58
- OpenSSL:
69
. Fixed bug GH-18986 (OpenSSL backend: incorrect RAND_{load,write}_file()
710
return value check). (nielsdos, botovq)
11+
. Fix error return check of EVP_CIPHER_CTX_ctrl(). (nielsdos)
812

913
31 Jul 2025, PHP 8.4.11
1014

ext/intl/collator/collator_sort.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ PHP_FUNCTION( collator_get_sort_key )
556556
key_len = ucol_getSortKey(co->ucoll, ustr, ustr_len, (uint8_t*)ZSTR_VAL(key_str), key_len);
557557
efree( ustr );
558558
if(!key_len) {
559+
zend_string_efree(key_str);
559560
RETURN_FALSE;
560561
}
561562
ZSTR_LEN(key_str) = key_len - 1;

ext/openssl/openssl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7692,7 +7692,7 @@ static int php_openssl_validate_iv(const char **piv, size_t *piv_len, size_t iv_
76927692
char *iv_new;
76937693

76947694
if (mode->is_aead) {
7695-
if (EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_ivlen_flag, *piv_len, NULL) != 1) {
7695+
if (EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_ivlen_flag, *piv_len, NULL) <= 0) {
76967696
php_error_docref(NULL, E_WARNING, "Setting of IV length for AEAD mode failed");
76977697
return FAILURE;
76987698
}
@@ -7764,15 +7764,15 @@ static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
77647764
return FAILURE;
77657765
}
77667766
if (mode->set_tag_length_always || (enc && mode->set_tag_length_when_encrypting)) {
7767-
if (!EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_set_tag_flag, tag_len, NULL)) {
7767+
if (EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_set_tag_flag, tag_len, NULL) <= 0) {
77687768
php_error_docref(NULL, E_WARNING, "Setting tag length for AEAD cipher failed");
77697769
return FAILURE;
77707770
}
77717771
}
77727772
if (!enc && tag && tag_len > 0) {
77737773
if (!mode->is_aead) {
77747774
php_error_docref(NULL, E_WARNING, "The tag cannot be used because the cipher algorithm does not support AEAD");
7775-
} else if (!EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_set_tag_flag, tag_len, (unsigned char *) tag)) {
7775+
} else if (EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_set_tag_flag, tag_len, (unsigned char *) tag) <= 0) {
77767776
php_error_docref(NULL, E_WARNING, "Setting tag for AEAD cipher decryption failed");
77777777
return FAILURE;
77787778
}
@@ -7910,7 +7910,7 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt(
79107910
if (mode.is_aead && tag) {
79117911
zend_string *tag_str = zend_string_alloc(tag_len, 0);
79127912

7913-
if (EVP_CIPHER_CTX_ctrl(cipher_ctx, mode.aead_get_tag_flag, tag_len, ZSTR_VAL(tag_str)) == 1) {
7913+
if (EVP_CIPHER_CTX_ctrl(cipher_ctx, mode.aead_get_tag_flag, tag_len, ZSTR_VAL(tag_str)) > 0) {
79147914
ZSTR_VAL(tag_str)[tag_len] = '\0';
79157915
ZSTR_LEN(tag_str) = tag_len;
79167916
ZEND_TRY_ASSIGN_REF_NEW_STR(tag, tag_str);

0 commit comments

Comments
 (0)