From b5be229cb7445f02e0bef8c47cb3de6355b5fd3b Mon Sep 17 00:00:00 2001 From: Ben Fuhrmannek Date: Sat, 7 Feb 2015 20:44:24 +0100 Subject: refactored srand() --- execute.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/execute.c b/execute.c index 6c8e0d4..8cdbd70 100644 --- a/execute.c +++ b/execute.c @@ -1426,21 +1426,23 @@ static php_uint32 suhosin_rand(TSRMLS_D) static int ih_srand(IH_HANDLER_PARAMS) { - int argc = ZEND_NUM_ARGS(); + int argc = ZEND_NUM_ARGS(); long seed; - if (zend_parse_parameters(argc TSRMLS_CC, "|l", &seed) == FAILURE || SUHOSIN_G(srand_ignore)) { - if (SUHOSIN_G(srand_ignore)) { - SUHOSIN_G(r_is_seeded) = 0; - } - return (1); - } + if (SUHOSIN_G(srand_ignore)) { + SUHOSIN_G(r_is_seeded) = 0; + return 1; + } + + if (zend_parse_parameters(argc TSRMLS_CC, "|l", &seed) == FAILURE) { + return 1; + } - if (argc == 0) { - suhosin_srand_auto(TSRMLS_C); - } else { - suhosin_srand(seed TSRMLS_CC); - } + if (argc) { + suhosin_srand(seed TSRMLS_CC); + } else { + suhosin_srand_auto(TSRMLS_C); + } return (1); } -- cgit v1.3