summaryrefslogtreecommitdiff
path: root/ext/standard/tests
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2015-02-20 10:01:00 +0100
committerOndřej Surý <ondrej@sury.org>2015-02-20 10:01:00 +0100
commit347aa01617585e89149414a9763175a19d2dc651 (patch)
tree98170e6aeca907f029fe7b5abbbd2e7f2f4a5412 /ext/standard/tests
parent832b62efb8fceebb220116d8024d945a9bd31d7e (diff)
downloadphp-upstream.tar.gz
New upstream version 5.6.6+dfsgupstream
Diffstat (limited to 'ext/standard/tests')
-rw-r--r--ext/standard/tests/file/bug65272.phpt26
-rw-r--r--ext/standard/tests/general_functions/bug60227_2.phpt7
-rw-r--r--ext/standard/tests/general_functions/bug60227_3.phpt6
-rw-r--r--ext/standard/tests/general_functions/bug60227_4.phpt6
-rw-r--r--ext/standard/tests/misc/exec_basic1.phpt25
-rw-r--r--ext/standard/tests/network/bug68925.phpt13
-rw-r--r--ext/standard/tests/streams/stream_multi_filters_close.phpt56
-rw-r--r--ext/standard/tests/strings/crypt_des_error.phpt16
8 files changed, 146 insertions, 9 deletions
diff --git a/ext/standard/tests/file/bug65272.phpt b/ext/standard/tests/file/bug65272.phpt
new file mode 100644
index 000000000..04a5c2d5d
--- /dev/null
+++ b/ext/standard/tests/file/bug65272.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #65272: flock() correctly sets wouldblock out param in windows
+--SKIPIF--
+<?php
+if (stripos(PHP_OS, 'win') !== 0) die("skip windows required");
+?>
+--FILE--
+<?php
+
+$file = dirname(__FILE__)."/flock.dat";
+
+$fp1 = fopen($file, "w");
+var_dump(flock($fp1, LOCK_SH));
+
+$fp2 = fopen($file, "r");
+var_dump(flock($fp2, LOCK_EX|LOCK_NB, $wouldblock));
+var_dump($wouldblock);
+
+@unlink($file);
+echo "Done\n";
+?>
+--EXPECTF--
+bool(true)
+bool(false)
+int(1)
+Done
diff --git a/ext/standard/tests/general_functions/bug60227_2.phpt b/ext/standard/tests/general_functions/bug60227_2.phpt
index 995c364ee..2cdde78a4 100644
--- a/ext/standard/tests/general_functions/bug60227_2.phpt
+++ b/ext/standard/tests/general_functions/bug60227_2.phpt
@@ -1,14 +1,15 @@
--TEST--
Bug #60227 (header() cannot detect the multi-line header with CR), \r before \n
+--INI--
+expose_php=0
--FILE--
<?php
header("X-foo: e\n foo");
-header("X-Foo6: e\rSet-Cookie: ID=123\n d");
echo 'foo';
?>
--EXPECTF--
+
Warning: Header may not contain more than a single header, new line detected in %s on line %d
foo
--EXPECTHEADERS--
-X-foo: e
-foo
+Content-type: text/html; charset=UTF-8
diff --git a/ext/standard/tests/general_functions/bug60227_3.phpt b/ext/standard/tests/general_functions/bug60227_3.phpt
index 8cba9b8ae..8246f1743 100644
--- a/ext/standard/tests/general_functions/bug60227_3.phpt
+++ b/ext/standard/tests/general_functions/bug60227_3.phpt
@@ -1,8 +1,9 @@
--TEST--
Bug #60227 (header() cannot detect the multi-line header with CR), \0 before \n
+--INI--
+expose_php=0
--FILE--
<?php
-header("X-foo: e\n foo");
header("X-Foo6: e\0Set-Cookie: ID=\n123\n d");
echo 'foo';
?>
@@ -10,5 +11,4 @@ echo 'foo';
Warning: Header may not contain NUL bytes in %s on line %d
foo
--EXPECTHEADERS--
-X-foo: e
-foo
+Content-type: text/html; charset=UTF-8
diff --git a/ext/standard/tests/general_functions/bug60227_4.phpt b/ext/standard/tests/general_functions/bug60227_4.phpt
index d5e2573d8..20dba1a26 100644
--- a/ext/standard/tests/general_functions/bug60227_4.phpt
+++ b/ext/standard/tests/general_functions/bug60227_4.phpt
@@ -1,8 +1,9 @@
--TEST--
Bug #60227 (header() cannot detect the multi-line header with CR), CRLF
+--INI--
+expose_php=0
--FILE--
<?php
-header("X-foo: e\r\n foo");
header("X-foo: e\r\nfoo");
echo 'foo';
?>
@@ -10,5 +11,4 @@ echo 'foo';
Warning: Header may not contain more than a single header, new line detected in %s on line %d
foo
--EXPECTHEADERS--
-X-foo: e
- foo
+Content-type: text/html; charset=UTF-8
diff --git a/ext/standard/tests/misc/exec_basic1.phpt b/ext/standard/tests/misc/exec_basic1.phpt
new file mode 100644
index 000000000..514c116d6
--- /dev/null
+++ b/ext/standard/tests/misc/exec_basic1.phpt
@@ -0,0 +1,25 @@
+--TEST--
+exec, system, passthru — Basic command execution functions
+--SKIPIF--
+<?php
+// If this does not work for Windows, please uncomment or fix test
+// if(substr(PHP_OS, 0, 3) == "WIN") die("skip not for Windows");
+?>
+--FILE--
+<?php
+$cmd = "echo abc\n\0command";
+var_dump(exec($cmd, $output));
+var_dump($output);
+var_dump(system($cmd));
+var_dump(passthru($cmd));
+?>
+--EXPECTF--
+Warning: exec(): NULL byte detected. Possible attack in %s on line %d
+bool(false)
+NULL
+
+Warning: system(): NULL byte detected. Possible attack in %s on line %d
+bool(false)
+
+Warning: passthru(): NULL byte detected. Possible attack in %s on line %d
+bool(false)
diff --git a/ext/standard/tests/network/bug68925.phpt b/ext/standard/tests/network/bug68925.phpt
new file mode 100644
index 000000000..2638dd331
--- /dev/null
+++ b/ext/standard/tests/network/bug68925.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #68925 (CVE-2015-0235 – GHOST: glibc gethostbyname buffer overflow)
+--FILE--
+<?php
+var_dump(gethostbyname(str_repeat("0", 2501)));
+var_dump(gethostbynamel(str_repeat("0", 2501)));
+?>
+--EXPECTF--
+Warning: gethostbyname(): Host name is too long, the limit is %d characters in %s/bug68925.php on line %d
+string(2501) "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
+
+Warning: gethostbynamel(): Host name is too long, the limit is %d characters in %s/bug68925.php on line %d
+bool(false)
diff --git a/ext/standard/tests/streams/stream_multi_filters_close.phpt b/ext/standard/tests/streams/stream_multi_filters_close.phpt
new file mode 100644
index 000000000..f1eb18a15
--- /dev/null
+++ b/ext/standard/tests/streams/stream_multi_filters_close.phpt
@@ -0,0 +1,56 @@
+--TEST--
+Check if multiple filters are closed correctly and never called again after close
+--FILE--
+<?php
+
+class FirstFilter extends php_user_filter {
+ public function filter($in, $out, &$consumed, $closing) {
+ static $closed = 0;
+
+ while ($bucket = stream_bucket_make_writeable($in)) {
+ stream_bucket_append($out, stream_bucket_new($this->stream, $bucket->data));
+ }
+
+ if ($closing) {
+ $closed++;
+ }
+
+ if ($closed > 0) {
+ var_dump($closed++);
+ }
+ return PSFS_PASS_ON;
+ }
+}
+
+class SecondFilter extends php_user_filter {
+ public function filter($in, $out, &$consumed, $closing) {
+ static $closed = 0;
+
+ while ($bucket = stream_bucket_make_writeable($in)) {
+ stream_bucket_append($out, stream_bucket_new($this->stream, $bucket->data));
+ }
+
+ if ($closing) {
+ $closed++;
+ }
+
+ if ($closed > 0) {
+ var_dump($closed++);
+ }
+ return PSFS_PASS_ON;
+ }
+}
+
+$r = fopen("php://stdout", "w+");
+stream_filter_register("first", "FirstFilter");
+stream_filter_register("second", "SecondFilter");
+$first = stream_filter_prepend($r, "first", STREAM_FILTER_WRITE, []);
+$second = stream_filter_prepend($r, "second", STREAM_FILTER_WRITE, []);
+fwrite($r, "test\n");
+stream_filter_remove($second);
+stream_filter_remove($first);
+?>
+--EXPECT--
+test
+int(1)
+int(1)
diff --git a/ext/standard/tests/strings/crypt_des_error.phpt b/ext/standard/tests/strings/crypt_des_error.phpt
new file mode 100644
index 000000000..f480efc47
--- /dev/null
+++ b/ext/standard/tests/strings/crypt_des_error.phpt
@@ -0,0 +1,16 @@
+--TEST--
+crypt(): *0 should return *1
+--SKIPIF--
+<?php
+if (!function_exists('crypt')) {
+ die("SKIP crypt() is not available");
+}
+?>
+--FILE--
+<?php
+
+var_dump(crypt('foo', '*0'));
+
+?>
+--EXPECT--
+string(2) "*1"