Fix openssl_random_pseudo_bytes() always setting strong_result to true

This regressed in 62c7432f, prior to that commit the value was set to
false in case random number generation failed, but now even if an
exception is thrown it is set to true. This likely does not _really_
matter as the user will handle the exception, still the value in
$strong_result is observable.
This commit is contained in:
Niels Dossche 2025-03-30 23:51:58 +02:00
parent 74720a22f3
commit 0dc600c69a
No known key found for this signature in database
GPG key ID: B8A8AD166DF0E2E5

View file

@ -7961,17 +7961,15 @@ PHP_FUNCTION(openssl_random_pseudo_bytes)
RETURN_THROWS();
}
if (zstrong_result_returned) {
ZEND_TRY_ASSIGN_REF_FALSE(zstrong_result_returned);
}
if ((buffer = php_openssl_random_pseudo_bytes(buffer_length))) {
ZSTR_VAL(buffer)[buffer_length] = 0;
RETVAL_NEW_STR(buffer);
}
if (zstrong_result_returned) {
ZEND_TRY_ASSIGN_REF_TRUE(zstrong_result_returned);
}
} else if (zstrong_result_returned) {
ZEND_TRY_ASSIGN_REF_FALSE(zstrong_result_returned);
}
}
/* }}} */