Skip to content

Commit 0dc600c

Browse files
committed
Fix openssl_random_pseudo_bytes() always setting strong_result to true
This regressed in 62c7432, 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.
1 parent 74720a2 commit 0dc600c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

ext/openssl/openssl.c

+5-7
Original file line numberDiff line numberDiff line change
@@ -7961,17 +7961,15 @@ PHP_FUNCTION(openssl_random_pseudo_bytes)
79617961
RETURN_THROWS();
79627962
}
79637963

7964-
if (zstrong_result_returned) {
7965-
ZEND_TRY_ASSIGN_REF_FALSE(zstrong_result_returned);
7966-
}
7967-
79687964
if ((buffer = php_openssl_random_pseudo_bytes(buffer_length))) {
79697965
ZSTR_VAL(buffer)[buffer_length] = 0;
79707966
RETVAL_NEW_STR(buffer);
7971-
}
79727967

7973-
if (zstrong_result_returned) {
7974-
ZEND_TRY_ASSIGN_REF_TRUE(zstrong_result_returned);
7968+
if (zstrong_result_returned) {
7969+
ZEND_TRY_ASSIGN_REF_TRUE(zstrong_result_returned);
7970+
}
7971+
} else if (zstrong_result_returned) {
7972+
ZEND_TRY_ASSIGN_REF_FALSE(zstrong_result_returned);
79757973
}
79767974
}
79777975
/* }}} */

0 commit comments

Comments
 (0)