Skip to content

[pull] master from php:master #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 15, 2025
Merged
4 changes: 2 additions & 2 deletions Zend/zend_opcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ static void zend_check_finally_breakout(zend_op_array *op_array, uint32_t op_num
}
}

static uint32_t zend_get_brk_cont_target(const zend_op_array *op_array, const zend_op *opline) {
static uint32_t zend_get_brk_cont_target(const zend_op *opline) {
int nest_levels = opline->op2.num;
int array_offset = opline->op1.num;
zend_brk_cont_element *jmp_to;
Expand Down Expand Up @@ -1120,7 +1120,7 @@ ZEND_API void pass_two(zend_op_array *op_array)
case ZEND_BRK:
case ZEND_CONT:
{
uint32_t jmp_target = zend_get_brk_cont_target(op_array, opline);
uint32_t jmp_target = zend_get_brk_cont_target(opline);

if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) {
zend_check_finally_breakout(op_array, opline - op_array->opcodes, jmp_target);
Expand Down
8 changes: 4 additions & 4 deletions ext/hash/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ static void php_hash_do_hash(

php_hash_bin2hex(ZSTR_VAL(hex_digest), (unsigned char *) ZSTR_VAL(digest), ops->digest_size);
ZSTR_VAL(hex_digest)[2 * ops->digest_size] = 0;
zend_string_release_ex(digest, 0);
zend_string_efree(digest);
RETURN_NEW_STR(hex_digest);
}
}
Expand Down Expand Up @@ -542,7 +542,7 @@ static void php_hash_do_hash_hmac(
if (n < 0) {
efree(context);
efree(K);
zend_string_release(digest);
zend_string_efree(digest);
RETURN_FALSE;
}

Expand All @@ -568,7 +568,7 @@ static void php_hash_do_hash_hmac(

php_hash_bin2hex(ZSTR_VAL(hex_digest), (unsigned char *) ZSTR_VAL(digest), ops->digest_size);
ZSTR_VAL(hex_digest)[2 * ops->digest_size] = 0;
zend_string_release_ex(digest, 0);
zend_string_efree(digest);
RETURN_NEW_STR(hex_digest);
}
}
Expand Down Expand Up @@ -829,7 +829,7 @@ PHP_FUNCTION(hash_final)

php_hash_bin2hex(ZSTR_VAL(hex_digest), (unsigned char *) ZSTR_VAL(digest), digest_len);
ZSTR_VAL(hex_digest)[2 * digest_len] = 0;
zend_string_release_ex(digest, 0);
zend_string_efree(digest);
RETURN_NEW_STR(hex_digest);
}
}
Expand Down
1 change: 1 addition & 0 deletions ext/intl/collator/collator_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ PHP_FUNCTION( collator_get_sort_key )
key_len = ucol_getSortKey(co->ucoll, ustr, ustr_len, (uint8_t*)ZSTR_VAL(key_str), key_len);
efree( ustr );
if(!key_len) {
zend_string_efree(key_str);
RETURN_FALSE;
}
ZSTR_LEN(key_str) = key_len - 1;
Expand Down
12 changes: 6 additions & 6 deletions ext/openssl/openssl_backend_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ zend_result php_openssl_load_rand_file(const char * file, int *egdsocket, int *s
return SUCCESS;
#endif
}
if (file == NULL || !RAND_load_file(file, -1)) {
if (file == NULL || RAND_load_file(file, -1) < 0) {
if (RAND_status() == 0) {
php_openssl_store_errors();
php_error_docref(NULL, E_WARNING, "Unable to load random state; not enough random data!");
Expand All @@ -465,7 +465,7 @@ zend_result php_openssl_write_rand_file(const char * file, int egdsocket, int se
if (file == NULL) {
file = RAND_file_name(buffer, sizeof(buffer));
}
if (file == NULL || !RAND_write_file(file)) {
if (file == NULL || RAND_write_file(file) < 0) {
php_openssl_store_errors();
php_error_docref(NULL, E_WARNING, "Unable to write random state");
return FAILURE;
Expand Down Expand Up @@ -1671,7 +1671,7 @@ zend_result php_openssl_validate_iv(const char **piv, size_t *piv_len, size_t iv
char *iv_new;

if (mode->is_aead) {
if (EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_ivlen_flag, *piv_len, NULL) != 1) {
if (EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_ivlen_flag, *piv_len, NULL) <= 0) {
php_error_docref(NULL, E_WARNING, "Setting of IV length for AEAD mode failed");
return FAILURE;
}
Expand Down Expand Up @@ -1742,15 +1742,15 @@ zend_result php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
return FAILURE;
}
if (mode->set_tag_length_always || (enc && mode->set_tag_length_when_encrypting)) {
if (!EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_set_tag_flag, tag_len, NULL)) {
if (EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_set_tag_flag, tag_len, NULL) <= 0) {
php_error_docref(NULL, E_WARNING, "Setting tag length for AEAD cipher failed");
return FAILURE;
}
}
if (!enc && tag && tag_len > 0) {
if (!mode->is_aead) {
php_error_docref(NULL, E_WARNING, "The tag cannot be used because the cipher algorithm does not support AEAD");
} else if (!EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_set_tag_flag, tag_len, (unsigned char *) tag)) {
} else if (EVP_CIPHER_CTX_ctrl(cipher_ctx, mode->aead_set_tag_flag, tag_len, (unsigned char *) tag) <= 0) {
php_error_docref(NULL, E_WARNING, "Setting tag for AEAD cipher decryption failed");
return FAILURE;
}
Expand Down Expand Up @@ -1886,7 +1886,7 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt(
if (mode.is_aead && tag) {
zend_string *tag_str = zend_string_alloc(tag_len, 0);

if (EVP_CIPHER_CTX_ctrl(cipher_ctx, mode.aead_get_tag_flag, tag_len, ZSTR_VAL(tag_str)) == 1) {
if (EVP_CIPHER_CTX_ctrl(cipher_ctx, mode.aead_get_tag_flag, tag_len, ZSTR_VAL(tag_str)) > 0) {
ZSTR_VAL(tag_str)[tag_len] = '\0';
ZSTR_LEN(tag_str) = tag_len;
ZEND_TRY_ASSIGN_REF_NEW_STR(tag, tag_str);
Expand Down