Skip to content

Commit a6e76ac

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix inverted call to php_openssl_store_errors() Fix openssl_random_pseudo_bytes() always setting strong_result to true
2 parents d689ff6 + 5e68671 commit a6e76ac

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

ext/openssl/openssl.c

+6-9
Original file line numberDiff line numberDiff line change
@@ -8157,11 +8157,10 @@ PHP_OPENSSL_API zend_string* php_openssl_random_pseudo_bytes(zend_long buffer_le
81578157
PHP_OPENSSL_CHECK_LONG_TO_INT_NULL_RETURN(buffer_length, length);
81588158
PHP_OPENSSL_RAND_ADD_TIME();
81598159
if (RAND_bytes((unsigned char*)ZSTR_VAL(buffer), (int)buffer_length) <= 0) {
8160+
php_openssl_store_errors();
81608161
zend_string_release_ex(buffer, 0);
81618162
zend_throw_exception(zend_ce_exception, "Error reading from source device", 0);
81628163
return NULL;
8163-
} else {
8164-
php_openssl_store_errors();
81658164
}
81668165

81678166
return buffer;
@@ -8178,17 +8177,15 @@ PHP_FUNCTION(openssl_random_pseudo_bytes)
81788177
RETURN_THROWS();
81798178
}
81808179

8181-
if (zstrong_result_returned) {
8182-
ZEND_TRY_ASSIGN_REF_FALSE(zstrong_result_returned);
8183-
}
8184-
81858180
if ((buffer = php_openssl_random_pseudo_bytes(buffer_length))) {
81868181
ZSTR_VAL(buffer)[buffer_length] = 0;
81878182
RETVAL_NEW_STR(buffer);
8188-
}
81898183

8190-
if (zstrong_result_returned) {
8191-
ZEND_TRY_ASSIGN_REF_TRUE(zstrong_result_returned);
8184+
if (zstrong_result_returned) {
8185+
ZEND_TRY_ASSIGN_REF_TRUE(zstrong_result_returned);
8186+
}
8187+
} else if (zstrong_result_returned) {
8188+
ZEND_TRY_ASSIGN_REF_FALSE(zstrong_result_returned);
81928189
}
81938190
}
81948191
/* }}} */

0 commit comments

Comments
 (0)