raven-rhel6/isp-php54/bug71323.patch

1492 lines
30 KiB
Diff
Raw Permalink Normal View History

2024-02-21 20:14:44 +06:00
Backported from 5.5 for 5.4 by Remi Collet
From 6297a117d77fa3a0df2e21ca926a92c231819cd5 Mon Sep 17 00:00:00 2001
From: Stanislav Malyshev <stas@php.net>
Date: Sat, 16 Jan 2016 22:10:54 -0800
Subject: [PATCH] Fixed bug #71323 - Output of stream_get_meta_data can be
falsified by its input
---
ext/standard/streamsfuncs.c | 20 ++--
ext/standard/tests/streams/bug71323.phpt | 31 ++++++
.../streams/stream_get_meta_data_dir_basic.phpt | 16 ++--
.../streams/stream_get_meta_data_file_basic.phpt | 12 +--
.../stream_get_meta_data_file_variation1.phpt | 104 ++++++++++-----------
.../stream_get_meta_data_file_variation2.phpt | 46 ++++-----
.../stream_get_meta_data_file_variation4.phpt | 20 ++--
.../stream_get_meta_data_file_variation5.phpt | 24 ++---
.../stream_get_meta_data_process_basic.phpt | 12 +--
.../streams/stream_get_meta_data_socket_basic.phpt | 12 +--
.../stream_get_meta_data_socket_variation1.phpt | 44 ++++-----
.../stream_get_meta_data_socket_variation2.phpt | 46 ++++-----
.../stream_get_meta_data_socket_variation3.phpt | 36 +++----
.../stream_get_meta_data_socket_variation4.phpt | 34 +++----
main/streams/memory.c | 30 +++---
15 files changed, 260 insertions(+), 227 deletions(-)
create mode 100644 ext/standard/tests/streams/bug71323.phpt
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c
index 4c2837e..d11f111 100644
--- a/ext/standard/streamsfuncs.c
+++ b/ext/standard/streamsfuncs.c
@@ -496,6 +496,12 @@ PHP_FUNCTION(stream_get_meta_data)
array_init(return_value);
+ if (!php_stream_populate_meta_data(stream, return_value)) {
+ add_assoc_bool(return_value, "timed_out", 0);
+ add_assoc_bool(return_value, "blocked", 1);
+ add_assoc_bool(return_value, "eof", php_stream_eof(stream));
+ }
+
if (stream->wrapperdata) {
MAKE_STD_ZVAL(newval);
MAKE_COPY_ZVAL(&stream->wrapperdata, newval);
@@ -531,12 +537,6 @@ PHP_FUNCTION(stream_get_meta_data)
add_assoc_string(return_value, "uri", stream->orig_path, 1);
}
- if (!php_stream_populate_meta_data(stream, return_value)) {
- add_assoc_bool(return_value, "timed_out", 0);
- add_assoc_bool(return_value, "blocked", 1);
- add_assoc_bool(return_value, "eof", php_stream_eof(stream));
- }
-
}
/* }}} */
diff --git a/ext/standard/tests/streams/bug71323.phpt b/ext/standard/tests/streams/bug71323.phpt
new file mode 100644
index 0000000..dfe0bd8
--- /dev/null
+++ b/ext/standard/tests/streams/bug71323.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Bug #71323: Output of stream_get_meta_data can be falsified by its input
+--FILE--
+<?php
+$file = 'data:text/plain;z=y;uri=eviluri;mediatype=wut?;mediatype2=hello,somedata';
+$meta = stream_get_meta_data(fopen($file, "r"));
+var_dump($meta);
+?>
+--EXPECTF--
+array(10) {
+ ["mediatype"]=>
+ string(10) "text/plain"
+ ["z"]=>
+ string(1) "y"
+ ["uri"]=>
+ string(72) "data:text/plain;z=y;uri=eviluri;mediatype=wut?;mediatype2=hello,somedata"
+ ["mediatype2"]=>
+ string(5) "hello"
+ ["base64"]=>
+ bool(false)
+ ["wrapper_type"]=>
+ string(7) "RFC2397"
+ ["stream_type"]=>
+ string(7) "RFC2397"
+ ["mode"]=>
+ string(1) "r"
+ ["unread_bytes"]=>
+ int(0)
+ ["seekable"]=>
+ bool(true)
+}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_dir_basic.phpt b/ext/standard/tests/streams/stream_get_meta_data_dir_basic.phpt
index f46c8fd..6658d69 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_dir_basic.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_dir_basic.phpt
@@ -13,6 +13,12 @@ var_dump(stream_get_meta_data($dirObject->handle));
?>
--EXPECT--
array(8) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -23,14 +29,14 @@ array(8) {
int(0)
["seekable"]=>
bool(true)
+}
+array(8) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(8) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -41,10 +47,4 @@ array(8) {
int(0)
["seekable"]=>
bool(true)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_basic.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_basic.phpt
index 4758c75..bad5987 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_file_basic.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_file_basic.phpt
@@ -12,6 +12,12 @@ fclose($fp);
?>
--EXPECTF--
array(9) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -24,10 +30,4 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%sstream_get_meta_data_file_basic.php"
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_variation1.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_variation1.phpt
index 572653e..d54eb04 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_file_variation1.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_file_variation1.phpt
@@ -29,6 +29,12 @@ unlink($filename);
?>
--EXPECTF--
array(9) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -41,14 +47,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -61,14 +67,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -81,14 +87,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -101,14 +107,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -121,14 +127,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -141,14 +147,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -161,14 +167,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -181,14 +187,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -201,14 +207,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -221,14 +227,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -241,14 +247,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -261,14 +267,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -281,14 +287,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -301,14 +307,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -321,14 +327,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -341,14 +347,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -361,14 +367,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -381,14 +387,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -401,14 +407,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -421,14 +427,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -441,14 +447,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -461,14 +467,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -481,14 +487,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -501,10 +507,4 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_variation2.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_variation2.phpt
index d186cb7..6b3fde2 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_file_variation2.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_file_variation2.phpt
@@ -43,6 +43,12 @@ unlink($filename);
--EXPECTF--
Write some data to the file:
array(9) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -55,12 +61,6 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
@@ -68,6 +68,12 @@ Read a line of the file, causing data to be buffered:
string(15) "a line of data
"
array(9) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -80,17 +86,17 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+
+
+Read 20 bytes from the file:
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-
-
-Read 20 bytes from the file:
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -103,17 +109,17 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
Read entire file:
array(9) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(true)
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -126,10 +132,4 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(true)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_variation4.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_variation4.phpt
index c51d9bd..46a5ba5 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_file_variation4.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_file_variation4.phpt
@@ -28,6 +28,12 @@ unlink($filename);
--EXPECTF--
Create a file:
array(9) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -40,16 +46,16 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "File://%sstream_get_meta_data_file_variation4.php.tmp"
+}
+
+Change to file's directory and open with a relative path:
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-
-Change to file's directory and open with a relative path:
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -62,10 +68,4 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "stream_get_meta_data_file_variation4.php.tmp"
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_variation5.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_variation5.phpt
index 386b92f..22fcee4 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_file_variation5.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_file_variation5.phpt
@@ -33,6 +33,12 @@ unlink($filename);
--EXPECTF--
Write some data to the file:
array(9) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -45,17 +51,17 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s"
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
Read entire file:
array(9) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(true)
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -68,10 +74,4 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s"
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(true)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_process_basic.phpt b/ext/standard/tests/streams/stream_get_meta_data_process_basic.phpt
index 3f4dfbc..b7ab37c 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_process_basic.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_process_basic.phpt
@@ -18,6 +18,12 @@ echo "Done";
?>
--EXPECT--
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["stream_type"]=>
string(5) "STDIO"
["mode"]=>
@@ -26,11 +32,5 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
Done
diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_basic.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_basic.phpt
index 8605611..c5136ab 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_socket_basic.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_socket_basic.phpt
@@ -10,6 +10,12 @@ fclose($tcp_socket);
?>
--EXPECTF--
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -18,10 +24,4 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt
index 16b38d9..18d6a4a 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt
@@ -39,6 +39,12 @@ var_dump(stream_get_meta_data($client));
--EXPECTF--
Write some data:
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -47,17 +53,17 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
+}
+
+
+Read a line from the client, causing data to be buffered:
+array(7) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-
-
-Read a line from the client, causing data to be buffered:
-array(7) {
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -66,17 +72,17 @@ array(7) {
int(15)
["seekable"]=>
bool(false)
+}
+
+
+Read 3 bytes of data from the client:
+array(7) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-
-
-Read 3 bytes of data from the client:
-array(7) {
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -85,17 +91,17 @@ array(7) {
int(12)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
Close the server side socket and read the remaining data from the client:
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(true)
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -104,10 +110,4 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(true)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt
index d30fec7..712a661 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt
@@ -37,25 +37,12 @@ fclose($server);
?>
--EXPECTF--
array(7) {
- ["stream_type"]=>
- string(%d) "tcp_socke%s"
- ["mode"]=>
- string(2) "r+"
- ["unread_bytes"]=>
- int(0)
- ["seekable"]=>
- bool(false)
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-
-
-Set a timeout on the client and attempt a read:
-array(7) {
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -64,17 +51,17 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
+}
+
+
+Set a timeout on the client and attempt a read:
+array(7) {
["timed_out"]=>
bool(true)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-
-
-Write some data from the server:
-array(7) {
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -83,17 +70,17 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
+}
+
+
+Write some data from the server:
+array(7) {
["timed_out"]=>
bool(true)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-
-
-Read some data from the client:
-array(7) {
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -102,10 +89,23 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
+}
+
+
+Read some data from the client:
+array(7) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
+ ["stream_type"]=>
+ string(%d) "tcp_socke%s"
+ ["mode"]=>
+ string(2) "r+"
+ ["unread_bytes"]=>
+ int(0)
+ ["seekable"]=>
+ bool(false)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt
index 0b079cc..4198973 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt
@@ -32,6 +32,12 @@ fclose($server);
?>
--EXPECTF--
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -40,18 +46,18 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
Set blocking to false:
bool(true)
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(false)
+ ["eof"]=>
+ bool(false)
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -60,18 +66,18 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(false)
- ["eof"]=>
- bool(false)
}
Set blocking to true:
bool(true)
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -80,10 +86,4 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt
index f9ef747..50d7ddf 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt
@@ -37,6 +37,12 @@ fclose($client);
--EXPECTF--
Write some data:
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -45,17 +51,17 @@ array(7) {
int(%i)
["seekable"]=>
bool(false)
+}
+
+
+Read a line from the client:
+array(7) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-
-
-Read a line from the client:
-array(7) {
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -64,17 +70,17 @@ array(7) {
int(%i)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
Close the server side socket and read the remaining data from the client:
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(true)
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -83,10 +89,4 @@ array(7) {
int(%i)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(true)
}
diff --git a/main/streams/memory.c b/main/streams/memory.c
index d0f2511..eb31db3 100644
--- a/main/streams/memory.c
+++ b/main/streams/memory.c
@@ -674,7 +674,9 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, cha
plen = sep - path;
vlen = (semi ? semi - sep : mlen - plen) - 1 /* '=' */;
key = estrndup(path, plen);
- add_assoc_stringl_ex(meta, key, plen + 1, sep + 1, vlen, 1);
+ if (plen != sizeof("mediatype")-1 || memcmp(key, "mediatype", sizeof("mediatype")-1)) {
+ add_assoc_stringl_ex(meta, key, plen + 1, sep + 1, vlen, 1);
+ }
efree(key);
plen += vlen + 1;
mlen -= plen;
From 2a7d8c0a06de8123034b136b0c717576b6e36fae Mon Sep 17 00:00:00 2001
From: Stanislav Malyshev <stas@php.net>
Date: Mon, 1 Feb 2016 18:58:02 -0800
Subject: [PATCH] fix tests
---
ext/standard/tests/file/stream_rfc2397_002.phpt | 56 +++++++++++-----------
.../tests/network/socket_get_status_basic.phpt | 12 ++---
ext/zip/tests/stream_meta_data.phpt | 16 +++----
ext/zlib/tests/zlib_wrapper_meta_data_basic.phpt | 20 ++++----
4 files changed, 52 insertions(+), 52 deletions(-)
diff --git a/ext/standard/tests/file/stream_rfc2397_002.phpt b/ext/standard/tests/file/stream_rfc2397_002.phpt
index 980863b..1dce5ad 100644
--- a/ext/standard/tests/file/stream_rfc2397_002.phpt
+++ b/ext/standard/tests/file/stream_rfc2397_002.phpt
@@ -34,6 +34,8 @@ foreach($streams as $stream)
<?php exit(0); ?>
--EXPECTF--
array(7) {
+ ["base64"]=>
+ bool(false)
["wrapper_type"]=>
string(7) "RFC2397"
["stream_type"]=>
@@ -46,8 +48,6 @@ array(7) {
bool(true)
["uri"]=>
string(8) "data://,"
- ["base64"]=>
- bool(false)
}
NULL
@@ -55,6 +55,8 @@ Warning: fopen(data://): failed to open stream: rfc2397: no comma in URL in %sst
NULL
NULL
array(7) {
+ ["base64"]=>
+ bool(true)
["wrapper_type"]=>
string(7) "RFC2397"
["stream_type"]=>
@@ -67,8 +69,6 @@ array(7) {
bool(true)
["uri"]=>
string(15) "data://;base64,"
- ["base64"]=>
- bool(true)
}
NULL
@@ -84,6 +84,10 @@ Warning: fopen(data://foo=bar,): failed to open stream: rfc2397: illegal media t
NULL
NULL
array(8) {
+ ["mediatype"]=>
+ string(10) "text/plain"
+ ["base64"]=>
+ bool(false)
["wrapper_type"]=>
string(7) "RFC2397"
["stream_type"]=>
@@ -96,10 +100,6 @@ array(8) {
bool(true)
["uri"]=>
string(18) "data://text/plain,"
- ["mediatype"]=>
- string(10) "text/plain"
- ["base64"]=>
- bool(false)
}
NULL
@@ -107,6 +107,12 @@ Warning: fopen(data://text/plain;foo,): failed to open stream: rfc2397: illegal
NULL
NULL
array(9) {
+ ["mediatype"]=>
+ string(10) "text/plain"
+ ["foo"]=>
+ string(3) "bar"
+ ["base64"]=>
+ bool(false)
["wrapper_type"]=>
string(7) "RFC2397"
["stream_type"]=>
@@ -119,12 +125,6 @@ array(9) {
bool(true)
["uri"]=>
string(26) "data://text/plain;foo=bar,"
- ["mediatype"]=>
- string(10) "text/plain"
- ["foo"]=>
- string(3) "bar"
- ["base64"]=>
- bool(false)
}
string(3) "bar"
@@ -132,6 +132,12 @@ Warning: fopen(data://text/plain;foo=bar;bla,): failed to open stream: rfc2397:
NULL
NULL
array(9) {
+ ["mediatype"]=>
+ string(10) "text/plain"
+ ["foo"]=>
+ string(3) "bar"
+ ["base64"]=>
+ bool(true)
["wrapper_type"]=>
string(7) "RFC2397"
["stream_type"]=>
@@ -144,12 +150,6 @@ array(9) {
bool(true)
["uri"]=>
string(33) "data://text/plain;foo=bar;base64,"
- ["mediatype"]=>
- string(10) "text/plain"
- ["foo"]=>
- string(3) "bar"
- ["base64"]=>
- bool(true)
}
string(3) "bar"
@@ -157,6 +157,14 @@ Warning: fopen(data://text/plain;foo=bar;bar=baz): failed to open stream: rfc239
NULL
NULL
array(10) {
+ ["mediatype"]=>
+ string(10) "text/plain"
+ ["foo"]=>
+ string(3) "bar"
+ ["bar"]=>
+ string(3) "baz"
+ ["base64"]=>
+ bool(false)
["wrapper_type"]=>
string(7) "RFC2397"
["stream_type"]=>
@@ -169,14 +177,6 @@ array(10) {
bool(true)
["uri"]=>
string(34) "data://text/plain;foo=bar;bar=baz,"
- ["mediatype"]=>
- string(10) "text/plain"
- ["foo"]=>
- string(3) "bar"
- ["bar"]=>
- string(3) "baz"
- ["base64"]=>
- bool(false)
}
string(3) "bar"
===DONE===
diff --git a/ext/standard/tests/network/socket_get_status_basic.phpt b/ext/standard/tests/network/socket_get_status_basic.phpt
index 46215f9..32a8d9c 100644
--- a/ext/standard/tests/network/socket_get_status_basic.phpt
+++ b/ext/standard/tests/network/socket_get_status_basic.phpt
@@ -18,6 +18,12 @@ fclose($server);
?>
--EXPECTF--
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["stream_type"]=>
string(%d) "tcp_socket%S"
["mode"]=>
@@ -26,10 +32,4 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
diff --git a/ext/zip/tests/stream_meta_data.phpt b/ext/zip/tests/stream_meta_data.phpt
index bd08098..63f720a 100644
--- a/ext/zip/tests/stream_meta_data.phpt
+++ b/ext/zip/tests/stream_meta_data.phpt
@@ -35,6 +35,12 @@ fclose($fp);
?>
--EXPECTF--
array(8) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["stream_type"]=>
string(3) "zip"
["mode"]=>
@@ -45,14 +51,14 @@ array(8) {
bool(false)
["uri"]=>
string(3) "foo"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(11) "zip wrapper"
["stream_type"]=>
@@ -65,10 +71,4 @@ array(9) {
bool(false)
["uri"]=>
string(%d) "zip://%stest_with_comment.zip#foo"
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
diff --git a/ext/zlib/tests/zlib_wrapper_meta_data_basic.phpt b/ext/zlib/tests/zlib_wrapper_meta_data_basic.phpt
index 2f76b46..a9d208e 100644
--- a/ext/zlib/tests/zlib_wrapper_meta_data_basic.phpt
+++ b/ext/zlib/tests/zlib_wrapper_meta_data_basic.phpt
@@ -25,6 +25,12 @@ gzclose($h);
--EXPECTF--
no wrapper
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["stream_type"]=>
string(4) "ZLIB"
["mode"]=>
@@ -33,16 +39,16 @@ array(7) {
int(0)
["seekable"]=>
bool(true)
+}
+
+with wrapper
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-
-with wrapper
-array(9) {
["wrapper_type"]=>
string(4) "ZLIB"
["stream_type"]=>
@@ -55,11 +61,5 @@ array(9) {
bool(true)
["uri"]=>
string(%d) "compress.zlib://%s/004.txt.gz"
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
===DONE===
\ No newline at end of file