diff options
| -rw-r--r-- | config.m4 | 2 | ||||
| -rw-r--r-- | execute.c | 9 | ||||
| -rw-r--r-- | execute.h | 8 | ||||
| -rw-r--r-- | execute_rnd.c | 152 | ||||
| -rw-r--r-- | php_suhosin7.h | 28 | ||||
| -rw-r--r-- | suhosin7.c | 16 | ||||
| -rw-r--r-- | tests/misc/mt_srand_ignore_off.phpt | 20 | ||||
| -rw-r--r-- | tests/misc/mt_srand_ignore_on.phpt | 20 | ||||
| -rw-r--r-- | tests/misc/srand_ignore_off.phpt | 20 | ||||
| -rw-r--r-- | tests/misc/srand_ignore_on.phpt | 20 |
10 files changed, 215 insertions, 80 deletions
| @@ -5,7 +5,7 @@ PHP_ARG_ENABLE(suhosin7, whether to enable suhosin support, | |||
| 5 | [ --enable-suhosin7 Enable suhosin support]) | 5 | [ --enable-suhosin7 Enable suhosin support]) |
| 6 | 6 | ||
| 7 | if test "$PHP_SUHOSIN7" != "no"; then | 7 | if test "$PHP_SUHOSIN7" != "no"; then |
| 8 | PHP_NEW_EXTENSION(suhosin7, suhosin7.c ifilter.c memory_limit.c aes.c treat_data.c log.c execute.c execute_ih.c crypt.c cookiecrypt.c header.c, $ext_shared,, [-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1]) | 8 | PHP_NEW_EXTENSION(suhosin7, suhosin7.c ifilter.c memory_limit.c aes.c treat_data.c log.c execute.c execute_ih.c execute_rnd.c crypt.c cookiecrypt.c header.c, $ext_shared,, [-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1]) |
| 9 | PHP_ADD_EXTENSION_DEP(suhosin7, hash) | 9 | PHP_ADD_EXTENSION_DEP(suhosin7, hash) |
| 10 | echo "===== WARNING ============================================" | 10 | echo "===== WARNING ============================================" |
| 11 | echo " Suhosin7 for PHP 7 is in alpha stage at the moment and" | 11 | echo " Suhosin7 for PHP 7 is in alpha stage at the moment and" |
| @@ -23,7 +23,6 @@ | |||
| 23 | #include "config.h" | 23 | #include "config.h" |
| 24 | #endif | 24 | #endif |
| 25 | 25 | ||
| 26 | // #include <fcntl.h> | ||
| 27 | #include "php.h" | 26 | #include "php.h" |
| 28 | // #include "php_ini.h" | 27 | // #include "php_ini.h" |
| 29 | // #include "zend_hash.h" | 28 | // #include "zend_hash.h" |
| @@ -37,7 +36,6 @@ | |||
| 37 | #include "SAPI.h" | 36 | #include "SAPI.h" |
| 38 | #include "execute.h" | 37 | #include "execute.h" |
| 39 | 38 | ||
| 40 | // #include "sha256.h" | ||
| 41 | 39 | ||
| 42 | // #ifdef PHP_WIN32 | 40 | // #ifdef PHP_WIN32 |
| 43 | // # include "win32/fnmatch.h" | 41 | // # include "win32/fnmatch.h" |
| @@ -555,6 +553,13 @@ static suhosin_internal_function_handler ihandlers[] = { | |||
| 555 | // { "mail", ih_mail, NULL, NULL, NULL }, | 553 | // { "mail", ih_mail, NULL, NULL, NULL }, |
| 556 | // { "symlink", ih_symlink, NULL, NULL, NULL }, | 554 | // { "symlink", ih_symlink, NULL, NULL, NULL }, |
| 557 | 555 | ||
| 556 | // random number functions | ||
| 557 | S7_IH_ENTRY0i(srand) | ||
| 558 | S7_IH_ENTRY0i(mt_srand) | ||
| 559 | S7_IH_ENTRY0i(rand) | ||
| 560 | S7_IH_ENTRY0i(mt_rand) | ||
| 561 | S7_IH_ENTRY0i(getrandmax) | ||
| 562 | S7_IH_ENTRY0("mt_getrandmax", getrandmax) | ||
| 558 | // { "srand", ih_srand, NULL, NULL, NULL }, | 563 | // { "srand", ih_srand, NULL, NULL, NULL }, |
| 559 | // { "mt_srand", ih_mt_srand, NULL, NULL, NULL }, | 564 | // { "mt_srand", ih_mt_srand, NULL, NULL, NULL }, |
| 560 | // { "rand", ih_rand, NULL, NULL, NULL }, | 565 | // { "rand", ih_rand, NULL, NULL, NULL }, |
| @@ -18,4 +18,12 @@ typedef struct _suhosin_internal_function_handler { | |||
| 18 | void *arg3; | 18 | void *arg3; |
| 19 | } suhosin_internal_function_handler; | 19 | } suhosin_internal_function_handler; |
| 20 | 20 | ||
| 21 | // execute_ih.c | ||
| 21 | S7_IH_FUNCTION(preg_replace); | 22 | S7_IH_FUNCTION(preg_replace); |
| 23 | |||
| 24 | // execute_rnd.c | ||
| 25 | S7_IH_FUNCTION(srand); | ||
| 26 | S7_IH_FUNCTION(mt_srand); | ||
| 27 | S7_IH_FUNCTION(mt_rand); | ||
| 28 | S7_IH_FUNCTION(rand); | ||
| 29 | S7_IH_FUNCTION(getrandmax); | ||
diff --git a/execute_rnd.c b/execute_rnd.c index 9647b63..e2f6016 100644 --- a/execute_rnd.c +++ b/execute_rnd.c | |||
| @@ -1,5 +1,26 @@ | |||
| 1 | /* | ||
| 2 | +----------------------------------------------------------------------+ | ||
| 3 | | Suhosin Version 1 | | ||
| 4 | +----------------------------------------------------------------------+ | ||
| 5 | | Copyright (c) 2006-2007 The Hardened-PHP Project | | ||
| 6 | | Copyright (c) 2007-2016 SektionEins GmbH | | ||
| 7 | +----------------------------------------------------------------------+ | ||
| 8 | | This source file is subject to version 3.01 of the PHP license, | | ||
| 9 | | that is bundled with this package in the file LICENSE, and is | | ||
| 10 | | available through the world-wide-web at the following url: | | ||
| 11 | | http://www.php.net/license/3_01.txt | | ||
| 12 | | If you did not receive a copy of the PHP license and are unable to | | ||
| 13 | | obtain it through the world-wide-web, please send a note to | | ||
| 14 | | license@php.net so we can mail you a copy immediately. | | ||
| 15 | +----------------------------------------------------------------------+ | ||
| 16 | | Authors: Stefan Esser <sesser@sektioneins.de> | | ||
| 17 | | Ben Fuhrmannek <ben.fuhrmannek@sektioneins.de> | | ||
| 18 | +----------------------------------------------------------------------+ | ||
| 19 | */ | ||
| 20 | |||
| 1 | /* MT RAND FUNCTIONS */ | 21 | /* MT RAND FUNCTIONS */ |
| 2 | 22 | ||
| 23 | |||
| 3 | /* | 24 | /* |
| 4 | The following php_mt_...() functions are based on a C++ class MTRand by | 25 | The following php_mt_...() functions are based on a C++ class MTRand by |
| 5 | Richard J. Wagner. For more information see the web page at | 26 | Richard J. Wagner. For more information see the web page at |
| @@ -55,12 +76,27 @@ | |||
| 55 | The original code included the following notice: | 76 | The original code included the following notice: |
| 56 | 77 | ||
| 57 | When you use this, send an email to: matumoto@math.keio.ac.jp | 78 | When you use this, send an email to: matumoto@math.keio.ac.jp |
| 58 | with an appropriate reference to your work. | 79 | with an appropriate reference to your work. |
| 59 | 80 | ||
| 60 | It would be nice to CC: rjwagner@writeme.com and Cokus@math.washington.edu | 81 | It would be nice to CC: rjwagner@writeme.com and Cokus@math.washington.edu |
| 61 | when you write. | 82 | when you write. |
| 62 | */ | 83 | */ |
| 63 | 84 | ||
| 85 | #ifdef HAVE_CONFIG_H | ||
| 86 | #include "config.h" | ||
| 87 | #endif | ||
| 88 | |||
| 89 | #include "php.h" | ||
| 90 | #include "php_suhosin7.h" | ||
| 91 | #include "ext/hash/php_hash.h" | ||
| 92 | #include "ext/hash/php_hash_sha.h" | ||
| 93 | #include "ext/standard/php_lcg.h" | ||
| 94 | #include "ext/standard/php_rand.h" | ||
| 95 | #include "execute.h" | ||
| 96 | |||
| 97 | #include <fcntl.h> | ||
| 98 | |||
| 99 | |||
| 64 | #define N 624 /* length of state vector */ | 100 | #define N 624 /* length of state vector */ |
| 65 | #define M (397) /* a period parameter */ | 101 | #define M (397) /* a period parameter */ |
| 66 | #define hiBit(u) ((u) & 0x80000000U) /* mask all but highest bit of u */ | 102 | #define hiBit(u) ((u) & 0x80000000U) /* mask all but highest bit of u */ |
| @@ -93,21 +129,21 @@ static inline void suhosin_mt_initialize(php_uint32 seed, php_uint32 *state) | |||
| 93 | 129 | ||
| 94 | static inline void suhosin_mt_init_by_array(php_uint32 *key, int keylen, php_uint32 *state) | 130 | static inline void suhosin_mt_init_by_array(php_uint32 *key, int keylen, php_uint32 *state) |
| 95 | { | 131 | { |
| 96 | int i, j, k; | 132 | int i, j, k; |
| 97 | suhosin_mt_initialize(19650218U, state); | 133 | suhosin_mt_initialize(19650218U, state); |
| 98 | i = 1; j = 0; | 134 | i = 1; j = 0; |
| 99 | k = (N > keylen ? N : keylen); | 135 | k = (N > keylen ? N : keylen); |
| 100 | for (; k; k--) { | 136 | for (; k; k--) { |
| 101 | state[i] = (state[i] ^ ((state[i-1] ^ (state[i-1] >> 30)) * 1664525U)) + key[j] + j; | 137 | state[i] = (state[i] ^ ((state[i-1] ^ (state[i-1] >> 30)) * 1664525U)) + key[j] + j; |
| 102 | i++; j = (j+1) % keylen; | 138 | i++; j = (j+1) % keylen; |
| 103 | if (i >= N) { state[0] = state[N-1]; i=1; } | 139 | if (i >= N) { state[0] = state[N-1]; i=1; } |
| 104 | } | 140 | } |
| 105 | for (k=N-1; k; k--) { | 141 | for (k=N-1; k; k--) { |
| 106 | state[i] = (state[i] ^ ((state[i-1] ^ (state[i-1] >> 30)) * 1566083941U)) - i; | 142 | state[i] = (state[i] ^ ((state[i-1] ^ (state[i-1] >> 30)) * 1566083941U)) - i; |
| 107 | i++; | 143 | i++; |
| 108 | if (i >= N) { state[0] = state[N-1]; i=1; } | 144 | if (i >= N) { state[0] = state[N-1]; i=1; } |
| 109 | } | 145 | } |
| 110 | state[0] = 0x80000000U; | 146 | state[0] = 0x80000000U; |
| 111 | } | 147 | } |
| 112 | /* }}} */ | 148 | /* }}} */ |
| 113 | 149 | ||
| @@ -171,48 +207,54 @@ static php_uint32 suhosin_mt_rand() | |||
| 171 | */ | 207 | */ |
| 172 | static void SUHOSIN7_Gen_entropy(php_uint32 *entropybuf) | 208 | static void SUHOSIN7_Gen_entropy(php_uint32 *entropybuf) |
| 173 | { | 209 | { |
| 174 | php_uint32 seedbuf[20]; | 210 | php_uint32 seedbuf[20]; |
| 175 | /* On a modern OS code, stack and heap base are randomized */ | 211 | /* On a modern OS code, stack and heap base are randomized */ |
| 176 | unsigned long code_value = (unsigned long)SUHOSIN7_Gen_entropy; | 212 | unsigned long code_value = (unsigned long)SUHOSIN7_Gen_entropy; |
| 177 | unsigned long stack_value = (unsigned long)&code_value; | 213 | unsigned long stack_value = (unsigned long)&code_value; |
| 178 | unsigned long heap_value = (unsigned long)SUHOSIN7_G(r_state); | 214 | unsigned long heap_value = (unsigned long)SUHOSIN7_G(r_state); |
| 179 | suhosin_SHA256_CTX context; | 215 | PHP_SHA256_CTX context; |
| 180 | int fd; | 216 | int fd; |
| 181 | 217 | ||
| 182 | code_value ^= code_value >> 32; | 218 | code_value ^= code_value >> 32; |
| 183 | stack_value ^= stack_value >> 32; | 219 | stack_value ^= stack_value >> 32; |
| 184 | heap_value ^= heap_value >> 32; | 220 | heap_value ^= heap_value >> 32; |
| 185 | 221 | ||
| 186 | seedbuf[0] = code_value; | 222 | seedbuf[0] = code_value; |
| 187 | seedbuf[1] = stack_value; | 223 | seedbuf[1] = stack_value; |
| 188 | seedbuf[2] = heap_value; | 224 | seedbuf[2] = heap_value; |
| 189 | seedbuf[3] = time(0); | 225 | seedbuf[3] = time(0); |
| 190 | #ifdef PHP_WIN32 | 226 | #ifdef PHP_WIN32 |
| 191 | seedbuf[4] = GetCurrentProcessId(); | 227 | seedbuf[4] = GetCurrentProcessId(); |
| 192 | #else | 228 | #else |
| 193 | seedbuf[4] = getpid(); | 229 | seedbuf[4] = getpid(); |
| 194 | #endif | 230 | #endif |
| 195 | seedbuf[5] = (php_uint32) 0x7fffffff * php_combined_lcg(); | 231 | seedbuf[5] = (php_uint32) 0x7fffffff * php_combined_lcg(); |
| 196 | 232 | ||
| 197 | #ifndef PHP_WIN32 | 233 | #ifndef PHP_WIN32 |
| 198 | fd = VCWD_OPEN("/dev/urandom", O_RDONLY); | 234 | # if HAVE_DEV_URANDOM |
| 199 | if (fd >= 0) { | 235 | # ifdef VIRTUAL_DIR |
| 200 | /* ignore error case - if urandom doesn't give us any/enough random bytes */ | 236 | fd = VCWD_OPEN("/dev/urandom", O_RDONLY); |
| 201 | read(fd, &seedbuf[6], 8 * sizeof(php_uint32)); | 237 | # else |
| 202 | close(fd); | 238 | fd = open("/dev/urandom", O_RDONLY); |
| 203 | } | 239 | # endif |
| 240 | if (fd >= 0) { | ||
| 241 | /* ignore error case - if urandom doesn't give us any/enough random bytes */ | ||
| 242 | read(fd, &seedbuf[6], 8 * sizeof(php_uint32)); | ||
| 243 | close(fd); | ||
| 244 | } | ||
| 245 | # endif | ||
| 204 | #else | 246 | #else |
| 205 | /* we have to live with the possibility that this call fails */ | 247 | /* we have to live with the possibility that this call fails */ |
| 206 | php_win32_get_random_bytes((unsigned char*)&seedbuf[6], 8 * sizeof(php_uint32)); | 248 | php_win32_get_random_bytes((unsigned char*)&seedbuf[6], 8 * sizeof(php_uint32)); |
| 207 | #endif | 249 | #endif |
| 208 | 250 | ||
| 209 | suhosin_SHA256Init(&context); | 251 | PHP_SHA256Init(&context); |
| 210 | /* to our friends from Debian: yes this will add unitialized stack values to the entropy DO NOT REMOVE */ | 252 | /* to our friends from Debian: yes this will add unitialized stack values to the entropy DO NOT REMOVE */ |
| 211 | suhosin_SHA256Update(&context, (void *) seedbuf, sizeof(seedbuf)); | 253 | PHP_SHA256Update(&context, (void *) seedbuf, sizeof(seedbuf)); |
| 212 | if (SUHOSIN7_G(seedingkey) != NULL && *SUHOSIN7_G(seedingkey) != 0) { | 254 | if (SUHOSIN7_G(seedingkey) != NULL && *SUHOSIN7_G(seedingkey) != 0) { |
| 213 | suhosin_SHA256Update(&context, (unsigned char*)SUHOSIN7_G(seedingkey), strlen(SUHOSIN7_G(seedingkey))); | 255 | PHP_SHA256Update(&context, (unsigned char*)SUHOSIN7_G(seedingkey), strlen(SUHOSIN7_G(seedingkey))); |
| 214 | } | 256 | } |
| 215 | suhosin_SHA256Final((void *)entropybuf, &context); | 257 | PHP_SHA256Final((void *)entropybuf, &context); |
| 216 | } | 258 | } |
| 217 | /* }}} */ | 259 | /* }}} */ |
| 218 | 260 | ||
| @@ -283,7 +325,7 @@ static php_uint32 suhosin_rand() | |||
| 283 | } | 325 | } |
| 284 | /* }}} */ | 326 | /* }}} */ |
| 285 | 327 | ||
| 286 | static int ih_srand(IH_HANDLER_PARAMS) | 328 | S7_IH_FUNCTION(srand) |
| 287 | { | 329 | { |
| 288 | int argc = ZEND_NUM_ARGS(); | 330 | int argc = ZEND_NUM_ARGS(); |
| 289 | long seed; | 331 | long seed; |
| @@ -305,7 +347,7 @@ static int ih_srand(IH_HANDLER_PARAMS) | |||
| 305 | return (1); | 347 | return (1); |
| 306 | } | 348 | } |
| 307 | 349 | ||
| 308 | static int ih_mt_srand(IH_HANDLER_PARAMS) | 350 | S7_IH_FUNCTION(mt_srand) |
| 309 | { | 351 | { |
| 310 | int argc = ZEND_NUM_ARGS(); | 352 | int argc = ZEND_NUM_ARGS(); |
| 311 | long seed; | 353 | long seed; |
| @@ -327,7 +369,7 @@ static int ih_mt_srand(IH_HANDLER_PARAMS) | |||
| 327 | return 1; | 369 | return 1; |
| 328 | } | 370 | } |
| 329 | 371 | ||
| 330 | static int ih_mt_rand(IH_HANDLER_PARAMS) | 372 | S7_IH_FUNCTION(mt_rand) |
| 331 | { | 373 | { |
| 332 | int argc = ZEND_NUM_ARGS(); | 374 | int argc = ZEND_NUM_ARGS(); |
| 333 | long min; | 375 | long min; |
| @@ -351,7 +393,7 @@ static int ih_mt_rand(IH_HANDLER_PARAMS) | |||
| 351 | return (1); | 393 | return (1); |
| 352 | } | 394 | } |
| 353 | 395 | ||
| 354 | static int ih_rand(IH_HANDLER_PARAMS) | 396 | S7_IH_FUNCTION(rand) |
| 355 | { | 397 | { |
| 356 | int argc = ZEND_NUM_ARGS(); | 398 | int argc = ZEND_NUM_ARGS(); |
| 357 | long min; | 399 | long min; |
| @@ -375,7 +417,7 @@ static int ih_rand(IH_HANDLER_PARAMS) | |||
| 375 | return (1); | 417 | return (1); |
| 376 | } | 418 | } |
| 377 | 419 | ||
| 378 | static int ih_getrandmax(IH_HANDLER_PARAMS) | 420 | S7_IH_FUNCTION(getrandmax) |
| 379 | { | 421 | { |
| 380 | if (zend_parse_parameters_none() == FAILURE) { | 422 | if (zend_parse_parameters_none() == FAILURE) { |
| 381 | return(0); | 423 | return(0); |
diff --git a/php_suhosin7.h b/php_suhosin7.h index 1e674ad..7a57fe1 100644 --- a/php_suhosin7.h +++ b/php_suhosin7.h | |||
| @@ -67,7 +67,7 @@ extern zend_module_entry suhosin7_module_entry; | |||
| 67 | // PHP_RSHUTDOWN_FUNCTION(suhosin); | 67 | // PHP_RSHUTDOWN_FUNCTION(suhosin); |
| 68 | // PHP_MINFO_FUNCTION(suhosin); | 68 | // PHP_MINFO_FUNCTION(suhosin); |
| 69 | 69 | ||
| 70 | // #include "ext/standard/basic_functions.h" | 70 | #include "ext/standard/basic_functions.h" |
| 71 | 71 | ||
| 72 | static inline int suhosin_is_protected_varname(char *var, int var_len) | 72 | static inline int suhosin_is_protected_varname(char *var, int var_len) |
| 73 | { | 73 | { |
| @@ -252,20 +252,20 @@ ZEND_BEGIN_MODULE_GLOBALS(suhosin7) | |||
| 252 | zend_bool disable_display_errors; | 252 | zend_bool disable_display_errors; |
| 253 | 253 | ||
| 254 | /* random number generator */ | 254 | /* random number generator */ |
| 255 | // php_uint32 r_state[625]; | 255 | php_uint32 r_state[625]; |
| 256 | // php_uint32 *r_next; | 256 | php_uint32 *r_next; |
| 257 | // int r_left; | 257 | int r_left; |
| 258 | // zend_bool srand_ignore; | 258 | zend_bool srand_ignore; |
| 259 | // zend_bool mt_srand_ignore; | 259 | zend_bool mt_srand_ignore; |
| 260 | // php_uint32 mt_state[625]; | 260 | php_uint32 mt_state[625]; |
| 261 | // php_uint32 *mt_next; | 261 | php_uint32 *mt_next; |
| 262 | // int mt_left; | 262 | int mt_left; |
| 263 | // | 263 | |
| 264 | // char *seedingkey; | 264 | char *seedingkey; |
| 265 | // zend_bool reseed_every_request; | 265 | zend_bool reseed_every_request; |
| 266 | // | 266 | // |
| 267 | // zend_bool r_is_seeded; | 267 | zend_bool r_is_seeded; |
| 268 | // zend_bool mt_is_seeded; | 268 | zend_bool mt_is_seeded; |
| 269 | 269 | ||
| 270 | 270 | ||
| 271 | /* memory_limit */ | 271 | /* memory_limit */ |
| @@ -407,10 +407,10 @@ PHP_INI_BEGIN() | |||
| 407 | STD_S7_INI_BOOLEAN("suhosin.server.encode", "1", PHP_INI_SYSTEM, OnUpdateBool, server_encode) | 407 | STD_S7_INI_BOOLEAN("suhosin.server.encode", "1", PHP_INI_SYSTEM, OnUpdateBool, server_encode) |
| 408 | STD_S7_INI_BOOLEAN("suhosin.server.strip", "1", PHP_INI_SYSTEM, OnUpdateBool, server_strip) | 408 | STD_S7_INI_BOOLEAN("suhosin.server.strip", "1", PHP_INI_SYSTEM, OnUpdateBool, server_strip) |
| 409 | // | 409 | // |
| 410 | // STD_S7_INI_ENTRY("suhosin.rand.seedingkey", "", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateMiscString, seedingkey) | 410 | STD_S7_INI_ENTRY("suhosin.rand.seedingkey", "", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateMiscString, seedingkey) |
| 411 | // STD_S7_INI_BOOLEAN("suhosin.rand.reseed_every_request", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateMiscBool, reseed_every_request) | 411 | STD_S7_INI_BOOLEAN("suhosin.rand.reseed_every_request", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateMiscBool, reseed_every_request) |
| 412 | // STD_S7_INI_BOOLEAN("suhosin.srand.ignore", "1", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateMiscBool, srand_ignore) | 412 | STD_S7_INI_BOOLEAN("suhosin.srand.ignore", "1", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateMiscBool, srand_ignore) |
| 413 | // STD_S7_INI_BOOLEAN("suhosin.mt_srand.ignore", "1", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateMiscBool, mt_srand_ignore) | 413 | STD_S7_INI_BOOLEAN("suhosin.mt_srand.ignore", "1", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateMiscBool, mt_srand_ignore) |
| 414 | 414 | ||
| 415 | 415 | ||
| 416 | PHP_INI_END() | 416 | PHP_INI_END() |
| @@ -576,10 +576,10 @@ PHP_RSHUTDOWN_FUNCTION(suhosin7) | |||
| 576 | 576 | ||
| 577 | SUHOSIN7_G(abort_request) = 0; | 577 | SUHOSIN7_G(abort_request) = 0; |
| 578 | 578 | ||
| 579 | // if (SUHOSIN7_G(reseed_every_request)) { | 579 | if (SUHOSIN7_G(reseed_every_request)) { |
| 580 | // SUHOSIN7_G(r_is_seeded) = 0; | 580 | SUHOSIN7_G(r_is_seeded) = 0; |
| 581 | // SUHOSIN7_G(mt_is_seeded) = 0; | 581 | SUHOSIN7_G(mt_is_seeded) = 0; |
| 582 | // } | 582 | } |
| 583 | 583 | ||
| 584 | if (SUHOSIN7_G(decrypted_cookie)) { | 584 | if (SUHOSIN7_G(decrypted_cookie)) { |
| 585 | efree(SUHOSIN7_G(decrypted_cookie)); | 585 | efree(SUHOSIN7_G(decrypted_cookie)); |
diff --git a/tests/misc/mt_srand_ignore_off.phpt b/tests/misc/mt_srand_ignore_off.phpt new file mode 100644 index 0000000..bc7f322 --- /dev/null +++ b/tests/misc/mt_srand_ignore_off.phpt | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | --TEST-- | ||
| 2 | Testing: suhosin.mt_srand.ignore=0 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php include "../skipif.inc"; ?> | ||
| 5 | --INI-- | ||
| 6 | suhosin.log.sapi=255 | ||
| 7 | suhosin.log.stdout=0 | ||
| 8 | suhosin.log.script=0 | ||
| 9 | suhosin.log.syslog=0 | ||
| 10 | suhosin.mt_srand.ignore=0 | ||
| 11 | --FILE-- | ||
| 12 | <?php | ||
| 13 | mt_srand(1); | ||
| 14 | $var1 = mt_rand(); | ||
| 15 | mt_srand(1); | ||
| 16 | $var2 = mt_rand(); | ||
| 17 | var_dump($var1 == $var2); | ||
| 18 | ?> | ||
| 19 | --EXPECTF-- | ||
| 20 | bool(true) | ||
diff --git a/tests/misc/mt_srand_ignore_on.phpt b/tests/misc/mt_srand_ignore_on.phpt new file mode 100644 index 0000000..8d276f7 --- /dev/null +++ b/tests/misc/mt_srand_ignore_on.phpt | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | --TEST-- | ||
| 2 | Testing: suhosin.mt_srand.ignore=1 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php include "../skipif.inc"; ?> | ||
| 5 | --INI-- | ||
| 6 | suhosin.log.sapi=255 | ||
| 7 | suhosin.log.stdout=0 | ||
| 8 | suhosin.log.script=0 | ||
| 9 | suhosin.log.syslog=0 | ||
| 10 | suhosin.mt_srand.ignore=1 | ||
| 11 | --FILE-- | ||
| 12 | <?php | ||
| 13 | mt_srand(1); | ||
| 14 | $var1 = mt_rand(); | ||
| 15 | mt_srand(1); | ||
| 16 | $var2 = mt_rand(); | ||
| 17 | var_dump($var1 != $var2); | ||
| 18 | ?> | ||
| 19 | --EXPECTF-- | ||
| 20 | bool(true) | ||
diff --git a/tests/misc/srand_ignore_off.phpt b/tests/misc/srand_ignore_off.phpt new file mode 100644 index 0000000..2f6f385 --- /dev/null +++ b/tests/misc/srand_ignore_off.phpt | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | --TEST-- | ||
| 2 | Testing: suhosin.srand.ignore=0 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php include "../skipif.inc"; ?> | ||
| 5 | --INI-- | ||
| 6 | suhosin.log.sapi=255 | ||
| 7 | suhosin.log.stdout=0 | ||
| 8 | suhosin.log.script=0 | ||
| 9 | suhosin.log.syslog=0 | ||
| 10 | suhosin.srand.ignore=0 | ||
| 11 | --FILE-- | ||
| 12 | <?php | ||
| 13 | srand(1); | ||
| 14 | $var1 = rand(); | ||
| 15 | srand(1); | ||
| 16 | $var2 = rand(); | ||
| 17 | var_dump($var1 == $var2); | ||
| 18 | ?> | ||
| 19 | --EXPECTF-- | ||
| 20 | bool(true) | ||
diff --git a/tests/misc/srand_ignore_on.phpt b/tests/misc/srand_ignore_on.phpt new file mode 100644 index 0000000..9f526b5 --- /dev/null +++ b/tests/misc/srand_ignore_on.phpt | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | --TEST-- | ||
| 2 | Testing: suhosin.srand.ignore=1 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php include "../skipif.inc"; ?> | ||
| 5 | --INI-- | ||
| 6 | suhosin.log.sapi=255 | ||
| 7 | suhosin.log.stdout=0 | ||
| 8 | suhosin.log.script=0 | ||
| 9 | suhosin.log.syslog=0 | ||
| 10 | suhosin.srand.ignore=1 | ||
| 11 | --FILE-- | ||
| 12 | <?php | ||
| 13 | srand(1); | ||
| 14 | $var1 = rand(); | ||
| 15 | srand(1); | ||
| 16 | $var2 = rand(); | ||
| 17 | var_dump($var1 != $var2); | ||
| 18 | ?> | ||
| 19 | --EXPECTF-- | ||
| 20 | bool(true) | ||
