Skip to content

Commit d742e11

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 c0b441f commit d742e11

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

ext/openssl/openssl.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7960,17 +7960,15 @@ PHP_FUNCTION(openssl_random_pseudo_bytes)
79607960
RETURN_THROWS();
79617961
}
79627962

7963-
if (zstrong_result_returned) {
7964-
ZEND_TRY_ASSIGN_REF_FALSE(zstrong_result_returned);
7965-
}
7966-
79677963
if ((buffer = php_openssl_random_pseudo_bytes(buffer_length))) {
79687964
ZSTR_VAL(buffer)[buffer_length] = 0;
79697965
RETVAL_NEW_STR(buffer);
7970-
}
79717966

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

0 commit comments

Comments
 (0)