summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/executor/memory_limit.phpt29
-rw-r--r--tests/executor/memory_limit_64bit.phpt43
-rw-r--r--tests/executor/memory_limit_64bit_10G.phpt36
-rw-r--r--tests/executor/memory_limit_negative.phpt18
-rw-r--r--tests/executor/memory_limit_other_hardlimit.phpt28
5 files changed, 154 insertions, 0 deletions
diff --git a/tests/executor/memory_limit.phpt b/tests/executor/memory_limit.phpt
new file mode 100644
index 0000000..404ab19
--- /dev/null
+++ b/tests/executor/memory_limit.phpt
@@ -0,0 +1,29 @@
1--TEST--
2memory_limit test: set suhosin hard_limit to normal limit
3--SKIPIF--
4<?php if (!function_exists("memory_get_usage")) print "skip PHP not compiled with memory_limit support"; ?>
5--INI--
6memory_limit=16M
7suhosin.memory_limit=0
8suhosin.log.syslog=0
9suhosin.log.script=0
10suhosin.log.sapi=2
11--FILE--
12<?php
13 ini_set("memory_limit", "13M"); echo ini_get("memory_limit"), "\n";
14 ini_set("memory_limit", "14M"); echo ini_get("memory_limit"), "\n";
15 ini_set("memory_limit", "15M"); echo ini_get("memory_limit"), "\n";
16 ini_set("memory_limit", "16M"); echo ini_get("memory_limit"), "\n";
17 ini_set("memory_limit", "17M"); echo ini_get("memory_limit"), "\n";
18 ini_set("memory_limit", "18M"); echo ini_get("memory_limit"), "\n";
19?>
20--EXPECTF--
2113M
2214M
2315M
2416M
25ALERT - script tried to increase memory_limit to 17825792 bytes which is above the allowed value (attacker 'REMOTE_ADDR not set', file '%s', line 6)
2616M
27ALERT - script tried to increase memory_limit to 18874368 bytes which is above the allowed value (attacker 'REMOTE_ADDR not set', file '%s', line 7)
2816M
29
diff --git a/tests/executor/memory_limit_64bit.phpt b/tests/executor/memory_limit_64bit.phpt
new file mode 100644
index 0000000..35be80b
--- /dev/null
+++ b/tests/executor/memory_limit_64bit.phpt
@@ -0,0 +1,43 @@
1--TEST--
2memory_limit test: set suhosin hard_limit to normal limit (64 bit)
3--SKIPIF--
4<?php if (!function_exists("memory_get_usage")) print "skip PHP not compiled with memory_limit support";
5else if (PHP_INT_SIZE != 8) print "skip This is not a 64 bit system";
6?>
7--INI--
8memory_limit=16M
9suhosin.memory_limit=0
10suhosin.log.syslog=0
11suhosin.log.script=0
12suhosin.log.sapi=2
13--FILE--
14<?php
15 ini_set("memory_limit", "13M"); echo ini_get("memory_limit"), "\n";
16 ini_set("memory_limit", "14M"); echo ini_get("memory_limit"), "\n";
17 ini_set("memory_limit", "15M"); echo ini_get("memory_limit"), "\n";
18 ini_set("memory_limit", "16M"); echo ini_get("memory_limit"), "\n";
19 ini_set("memory_limit", "17M"); echo ini_get("memory_limit"), "\n";
20 ini_set("memory_limit", "18M"); echo ini_get("memory_limit"), "\n";
21 ini_set("memory_limit", "2G"); echo ini_get("memory_limit"), "\n";
22 ini_set("memory_limit", "3G"); echo ini_get("memory_limit"), "\n";
23 ini_set("memory_limit", "4G"); echo ini_get("memory_limit"), "\n";
24 ini_set("memory_limit", "5G"); echo ini_get("memory_limit"), "\n";
25?>
26--EXPECTF--
2713M
2814M
2915M
3016M
31ALERT - script tried to increase memory_limit to 17825792 bytes which is above the allowed value (attacker 'REMOTE_ADDR not set', file '%s', line 6)
3216M
33ALERT - script tried to increase memory_limit to 18874368 bytes which is above the allowed value (attacker 'REMOTE_ADDR not set', file '%s', line 7)
3416M
35ALERT - script tried to increase memory_limit to 2147483648 bytes which is above the allowed value (attacker 'REMOTE_ADDR not set', file '%s', line 8)
3616M
37ALERT - script tried to increase memory_limit to 3221225472 bytes which is above the allowed value (attacker 'REMOTE_ADDR not set', file '%s', line 9)
3816M
39ALERT - script tried to increase memory_limit to 4294967296 bytes which is above the allowed value (attacker 'REMOTE_ADDR not set', file '%s', line 10)
4016M
41ALERT - script tried to increase memory_limit to 5368709120 bytes which is above the allowed value (attacker 'REMOTE_ADDR not set', file '%s', line 11)
4216M
43
diff --git a/tests/executor/memory_limit_64bit_10G.phpt b/tests/executor/memory_limit_64bit_10G.phpt
new file mode 100644
index 0000000..284db50
--- /dev/null
+++ b/tests/executor/memory_limit_64bit_10G.phpt
@@ -0,0 +1,36 @@
1--TEST--
2memory_limit test: set suhosin hard_limit to normal limit (64 bit) - 10 GB
3--SKIPIF--
4<?php if (!function_exists("memory_get_usage")) print "skip PHP not compiled with memory_limit support";
5else if (PHP_INT_SIZE != 8) print "skip This is not a 64 bit system";
6?>
7--INI--
8memory_limit=10G
9suhosin.memory_limit=0
10suhosin.log.syslog=0
11suhosin.log.script=0
12suhosin.log.sapi=2
13--FILE--
14<?php
15 ini_set("memory_limit", "13M"); echo ini_get("memory_limit"), "\n";
16 ini_set("memory_limit", "14M"); echo ini_get("memory_limit"), "\n";
17 ini_set("memory_limit", "15M"); echo ini_get("memory_limit"), "\n";
18 ini_set("memory_limit", "16M"); echo ini_get("memory_limit"), "\n";
19 ini_set("memory_limit", "17M"); echo ini_get("memory_limit"), "\n";
20 ini_set("memory_limit", "18M"); echo ini_get("memory_limit"), "\n";
21 ini_set("memory_limit", "2G"); echo ini_get("memory_limit"), "\n";
22 ini_set("memory_limit", "3G"); echo ini_get("memory_limit"), "\n";
23 ini_set("memory_limit", "4G"); echo ini_get("memory_limit"), "\n";
24 ini_set("memory_limit", "5G"); echo ini_get("memory_limit"), "\n";
25?>
26--EXPECTF--
2713M
2814M
2915M
3016M
3117M
3218M
332G
343G
354G
365G
diff --git a/tests/executor/memory_limit_negative.phpt b/tests/executor/memory_limit_negative.phpt
new file mode 100644
index 0000000..7fad546
--- /dev/null
+++ b/tests/executor/memory_limit_negative.phpt
@@ -0,0 +1,18 @@
1--TEST--
2memory_limit test: trying to set memory_limit to a negative value
3--SKIPIF--
4<?php if (!function_exists("memory_get_usage")) print "skip PHP not compiled with memory_limit support"; ?>
5--INI--
6memory_limit=16M
7suhosin.memory_limit=17M
8suhosin.log.syslog=0
9suhosin.log.script=0
10suhosin.log.sapi=2
11--FILE--
12<?php
13 ini_set("memory_limit", "-200000"); echo ini_get("memory_limit"), "\n";
14?>
15--EXPECTF--
16ALERT - script tried to disable memory_limit by setting it to a negative value -%d bytes which is not allowed (attacker 'REMOTE_ADDR not set', file '%s', line 2)
1716M
18
diff --git a/tests/executor/memory_limit_other_hardlimit.phpt b/tests/executor/memory_limit_other_hardlimit.phpt
new file mode 100644
index 0000000..cac11dc
--- /dev/null
+++ b/tests/executor/memory_limit_other_hardlimit.phpt
@@ -0,0 +1,28 @@
1--TEST--
2memory_limit test: set suhosin hard_limit to normal limit + 1M
3--SKIPIF--
4<?php if (!function_exists("memory_get_usage")) print "skip PHP not compiled with memory_limit support"; ?>
5--INI--
6memory_limit=16M
7suhosin.memory_limit=17M
8suhosin.log.syslog=0
9suhosin.log.script=0
10suhosin.log.sapi=2
11--FILE--
12<?php
13 ini_set("memory_limit", "13M"); echo ini_get("memory_limit"), "\n";
14 ini_set("memory_limit", "14M"); echo ini_get("memory_limit"), "\n";
15 ini_set("memory_limit", "15M"); echo ini_get("memory_limit"), "\n";
16 ini_set("memory_limit", "16M"); echo ini_get("memory_limit"), "\n";
17 ini_set("memory_limit", "17M"); echo ini_get("memory_limit"), "\n";
18 ini_set("memory_limit", "18M"); echo ini_get("memory_limit"), "\n";
19?>
20--EXPECTF--
2113M
2214M
2315M
2416M
2517M
26ALERT - script tried to increase memory_limit to %d bytes which is above the allowed value (attacker 'REMOTE_ADDR not set', file '%s', line 7)
2717M
28