diff options
| author | Stefan Esser | 2014-02-11 12:40:38 +0100 |
|---|---|---|
| committer | Stefan Esser | 2014-02-11 12:40:38 +0100 |
| commit | a97451f504bd41db897cea6a93e557664b535f8b (patch) | |
| tree | c15ce01ebb9707bd9ac80303268bbcb04c76c73e /memory_limit.c | |
| parent | e7dfd0bc820e59cd8abd2e36b0320cfceb9701a8 (diff) | |
Fix year and some memory limit code
Diffstat (limited to 'memory_limit.c')
| -rw-r--r-- | memory_limit.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/memory_limit.c b/memory_limit.c index 9088e95..5dc20ce 100644 --- a/memory_limit.c +++ b/memory_limit.c | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | | Suhosin Version 1 | | 3 | | Suhosin Version 1 | |
| 4 | +----------------------------------------------------------------------+ | 4 | +----------------------------------------------------------------------+ |
| 5 | | Copyright (c) 2006-2007 The Hardened-PHP Project | | 5 | | Copyright (c) 2006-2007 The Hardened-PHP Project | |
| 6 | | Copyright (c) 2007-2012 SektionEins GmbH | | 6 | | Copyright (c) 2007-2014 SektionEins GmbH | |
| 7 | +----------------------------------------------------------------------+ | 7 | +----------------------------------------------------------------------+ |
| 8 | | This source file is subject to version 3.01 of the PHP license, | | 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 | | 9 | | that is bundled with this package in the file LICENSE, and is | |
| @@ -34,8 +34,11 @@ | |||
| 34 | */ | 34 | */ |
| 35 | static PHP_INI_MH(suhosin_OnChangeMemoryLimit) | 35 | static PHP_INI_MH(suhosin_OnChangeMemoryLimit) |
| 36 | { | 36 | { |
| 37 | long hard_memory_limit = 1<<30; | 37 | #if SIZEOF_LONG==8 |
| 38 | 38 | long hard_memory_limit = 1<<63; | |
| 39 | #elif SIZEOF_LONG==4 | ||
| 40 | long hard_memory_limit = 1<<31; | ||
| 41 | #endif /* will produce a compile error or SIZEOF_LONG is not 4 or 8 */ | ||
| 39 | if (stage == ZEND_INI_STAGE_RUNTIME) { | 42 | if (stage == ZEND_INI_STAGE_RUNTIME) { |
| 40 | if (SUHOSIN_G(memory_limit) > 0) { | 43 | if (SUHOSIN_G(memory_limit) > 0) { |
| 41 | SUHOSIN_G(hard_memory_limit) = SUHOSIN_G(memory_limit); | 44 | SUHOSIN_G(hard_memory_limit) = SUHOSIN_G(memory_limit); |
| @@ -50,13 +53,13 @@ static PHP_INI_MH(suhosin_OnChangeMemoryLimit) | |||
| 50 | PG(memory_limit) = zend_atol(new_value, new_value_length); | 53 | PG(memory_limit) = zend_atol(new_value, new_value_length); |
| 51 | if (hard_memory_limit > 0) { | 54 | if (hard_memory_limit > 0) { |
| 52 | if (PG(memory_limit) > hard_memory_limit) { | 55 | if (PG(memory_limit) > hard_memory_limit) { |
| 53 | suhosin_log(S_MISC, "script tried to increase memory_limit to %u bytes which is above the allowed value", PG(memory_limit)); | 56 | suhosin_log(S_MISC, "script tried to increase memory_limit to %lu bytes which is above the allowed value", PG(memory_limit)); |
| 54 | if (!SUHOSIN_G(simulation)) { | 57 | if (!SUHOSIN_G(simulation)) { |
| 55 | PG(memory_limit) = hard_memory_limit; | 58 | PG(memory_limit) = hard_memory_limit; |
| 56 | return FAILURE; | 59 | return FAILURE; |
| 57 | } | 60 | } |
| 58 | } else if (PG(memory_limit) < 0) { | 61 | } else if (PG(memory_limit) < 0) { |
| 59 | suhosin_log(S_MISC, "script tried to disable memory_limit by setting it to a negative value %d bytes which is not allowed", PG(memory_limit)); | 62 | suhosin_log(S_MISC, "script tried to disable memory_limit by setting it to a negative value %ld bytes which is not allowed", PG(memory_limit)); |
| 60 | if (!SUHOSIN_G(simulation)) { | 63 | if (!SUHOSIN_G(simulation)) { |
| 61 | PG(memory_limit) = hard_memory_limit; | 64 | PG(memory_limit) = hard_memory_limit; |
| 62 | return FAILURE; | 65 | return FAILURE; |
