Blame SOURCES/php-5.5.21-bug69353.patch

30ceb2
From 52b93f0cfd3cba7ff98cc5198df6ca4f23865f80 Mon Sep 17 00:00:00 2001
30ceb2
From: Stanislav Malyshev <stas@php.net>
30ceb2
Date: Sun, 5 Apr 2015 16:01:24 -0700
30ceb2
Subject: [PATCH] Fixed bug #69353 (Missing null byte checks for paths in
30ceb2
 various PHP extensions)
30ceb2
30ceb2
---
30ceb2
 ext/dom/document.c                                 | 5 ++++-
30ceb2
 ext/dom/tests/DOMDocument_loadHTMLfile_error2.phpt | 5 +++++
30ceb2
 ext/fileinfo/fileinfo.c                            | 5 +++++
30ceb2
 ext/fileinfo/tests/finfo_file_basic.phpt           | 4 ++++
30ceb2
 ext/gd/gd.c                                        | 8 ++++----
30ceb2
 ext/hash/hash.c                                    | 7 ++++++-
30ceb2
 ext/hash/tests/hash_hmac_file_error.phpt           | 7 +++++++
30ceb2
 ext/pgsql/pgsql.c                                  | 2 +-
30ceb2
 ext/standard/link.c                                | 2 +-
30ceb2
 ext/standard/streamsfuncs.c                        | 2 +-
30ceb2
 ext/xmlwriter/php_xmlwriter.c                      | 4 ++--
30ceb2
 ext/zlib/zlib.c                                    | 4 ++--
30ceb2
 12 files changed, 42 insertions(+), 13 deletions(-)
30ceb2
30ceb2
diff --git a/ext/dom/document.c b/ext/dom/document.c
30ceb2
index 18c9cc6..7c5817a 100644
30ceb2
--- a/ext/dom/document.c
30ceb2
+++ b/ext/dom/document.c
30ceb2
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc
30ceb2
 	xmlInitParser();
30ceb2
 
30ceb2
 	if (mode == DOM_LOAD_FILE) {
30ceb2
+		if (CHECK_NULL_PATH(source, source_len)) {
30ceb2
+			return NULL;
30ceb2
+		}
30ceb2
 		char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN  TSRMLS_CC);
30ceb2
 		if (file_dest) {
30ceb2
 			ctxt = xmlCreateFileParserCtxt(file_dest);
30ceb2
@@ -2176,7 +2179,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */
30ceb2
 	
30ceb2
 	id = getThis();
30ceb2
 
30ceb2
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) {
30ceb2
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) {
30ceb2
 		return;
30ceb2
 	}
30ceb2
 
30ceb2
diff --git a/ext/dom/tests/DOMDocument_loadHTMLfile_error2.phpt b/ext/dom/tests/DOMDocument_loadHTMLfile_error2.phpt
30ceb2
index e59ff56..75004e2 100644
30ceb2
--- a/ext/dom/tests/DOMDocument_loadHTMLfile_error2.phpt
30ceb2
+++ b/ext/dom/tests/DOMDocument_loadHTMLfile_error2.phpt
30ceb2
@@ -13,6 +13,11 @@ assert.bail=true
30ceb2
 $doc = new DOMDocument();
30ceb2
 $result = $doc->loadHTMLFile("");
30ceb2
 assert('$result === false');
30ceb2
+$doc = new DOMDocument();
30ceb2
+$result = $doc->loadHTMLFile("text.html\0something");
30ceb2
+assert('$result === null');
30ceb2
 ?>
30ceb2
 --EXPECTF--
30ceb2
 %r(PHP ){0,1}%rWarning: DOMDocument::loadHTMLFile(): Empty string supplied as input %s
30ceb2
+
30ceb2
+%r(PHP ){0,1}%rWarning: DOMDocument::loadHTMLFile() expects parameter 1 to be a valid path, string given %s
30ceb2
diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c
30ceb2
index ead7585..9f651af 100644
30ceb2
--- a/ext/fileinfo/fileinfo.c
30ceb2
+++ b/ext/fileinfo/fileinfo.c
30ceb2
@@ -506,6 +506,11 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
30ceb2
 				RETVAL_FALSE;
30ceb2
 				goto clean;
30ceb2
 			}
30ceb2
+			if (CHECK_NULL_PATH(buffer, buffer_len)) {
30ceb2
+				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid path");
30ceb2
+				RETVAL_FALSE;
30ceb2
+				goto clean;
30ceb2
+			}
30ceb2
 
30ceb2
 			wrap = php_stream_locate_url_wrapper(buffer, &tmp2, 0 TSRMLS_CC);
30ceb2
 
30ceb2
diff --git a/ext/fileinfo/tests/finfo_file_basic.phpt b/ext/fileinfo/tests/finfo_file_basic.phpt
30ceb2
index 20223fd..ee70e2e 100644
30ceb2
--- a/ext/fileinfo/tests/finfo_file_basic.phpt
30ceb2
+++ b/ext/fileinfo/tests/finfo_file_basic.phpt
30ceb2
@@ -19,6 +19,7 @@ echo "*** Testing finfo_file() : basic functionality ***\n";
30ceb2
 var_dump( finfo_file( $finfo, __FILE__) );
30ceb2
 var_dump( finfo_file( $finfo, __FILE__, FILEINFO_CONTINUE ) );
30ceb2
 var_dump( finfo_file( $finfo, $magicFile ) );
30ceb2
+var_dump( finfo_file( $finfo, $magicFile.chr(0).$magicFile) );
30ceb2
 
30ceb2
 ?>
30ceb2
 ===DONE===
30ceb2
@@ -27,4 +28,7 @@ var_dump( finfo_file( $finfo, $magicFile ) );
30ceb2
 string(28) "text/x-php; charset=us-ascii"
30ceb2
 string(22) "PHP script, ASCII text"
30ceb2
 string(25) "text/plain; charset=utf-8"
30ceb2
+
30ceb2
+Warning: finfo_file(): Invalid path in %s/finfo_file_basic.php on line %d
30ceb2
+bool(false)
30ceb2
 ===DONE===
30ceb2
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
30ceb2
index cbc1d2b..322325e 100644
30ceb2
--- a/ext/gd/gd.c
30ceb2
+++ b/ext/gd/gd.c
30ceb2
@@ -1417,7 +1417,7 @@ PHP_FUNCTION(imageloadfont)
30ceb2
 	gdFontPtr font;
30ceb2
 	php_stream *stream;
30ceb2
 
30ceb2
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_name) == FAILURE) {
30ceb2
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &file, &file_name) == FAILURE) {
30ceb2
 		return;
30ceb2
 	}
30ceb2
 
30ceb2
@@ -2354,7 +2354,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
30ceb2
 	long ignore_warning;
30ceb2
 
30ceb2
 	if (image_type == PHP_GDIMG_TYPE_GD2PART) {
30ceb2
-		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sllll", &file, &file_len, &srcx, &srcy, &width, &height) == FAILURE) {
30ceb2
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pllll", &file, &file_len, &srcx, &srcy, &width, &height) == FAILURE) {
30ceb2
 			return;
30ceb2
 		}
30ceb2
 		if (width < 1 || height < 1) {
30ceb2
@@ -2362,7 +2362,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
30ceb2
 			RETURN_FALSE;
30ceb2
 		}
30ceb2
 	} else {
30ceb2
-		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len) == FAILURE) {
30ceb2
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &file, &file_len) == FAILURE) {
30ceb2
 			return;
30ceb2
 		}
30ceb2
 	}
30ceb2
@@ -4031,7 +4031,7 @@ PHP_FUNCTION(imagepsencodefont)
30ceb2
 	char *enc, **enc_vector;
30ceb2
 	int enc_len, *f_ind;
30ceb2
 
30ceb2
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &fnt, &enc, &enc_len) == FAILURE) {
30ceb2
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rp", &fnt, &enc, &enc_len) == FAILURE) {
30ceb2
 		return;
30ceb2
 	}
30ceb2
 
30ceb2
diff --git a/ext/hash/hash.c b/ext/hash/hash.c
30ceb2
index abdc62b..9cd6b8e 100644
30ceb2
--- a/ext/hash/hash.c
30ceb2
+++ b/ext/hash/hash.c
30ceb2
@@ -143,6 +143,7 @@ static void php_hash_do_hash(INTERNAL_FUNCTION_PARAMETERS, int isfilename, zend_
30ceb2
 	}
30ceb2
 	if (isfilename) {
30ceb2
 		if (CHECK_NULL_PATH(data, data_len)) {
30ceb2
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid path");
30ceb2
 			RETURN_FALSE;
30ceb2
 		}
30ceb2
 		stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, DEFAULT_CONTEXT);
30ceb2
@@ -258,6 +259,10 @@ static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int isfilename,
30ceb2
 		RETURN_FALSE;
30ceb2
 	}
30ceb2
 	if (isfilename) {
30ceb2
+		if (CHECK_NULL_PATH(data, data_len)) {
30ceb2
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid path");
30ceb2
+			RETURN_FALSE;
30ceb2
+		}
30ceb2
 		stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, DEFAULT_CONTEXT);
30ceb2
 		if (!stream) {
30ceb2
 			/* Stream will report errors opening file */
30ceb2
@@ -462,7 +467,7 @@ PHP_FUNCTION(hash_update_file)
30ceb2
 	char *filename, buf[1024];
30ceb2
 	int filename_len, n;
30ceb2
 
30ceb2
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|r", &zhash, &filename, &filename_len, &zcontext) == FAILURE) {
30ceb2
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rp|r", &zhash, &filename, &filename_len, &zcontext) == FAILURE) {
30ceb2
 		return;
30ceb2
 	}
30ceb2
 
30ceb2
diff --git a/ext/hash/tests/hash_hmac_file_error.phpt b/ext/hash/tests/hash_hmac_file_error.phpt
30ceb2
index 42ab122..26ba8aa 100644
30ceb2
--- a/ext/hash/tests/hash_hmac_file_error.phpt
30ceb2
+++ b/ext/hash/tests/hash_hmac_file_error.phpt
30ceb2
@@ -28,6 +28,9 @@ hash_hmac_file('crc32', $file, $key, TRUE, $extra_arg);
30ceb2
 echo "\n-- Testing hash_hmac_file() function with invalid hash algorithm --\n";
30ceb2
 hash_hmac_file('foo', $file, $key, TRUE);
30ceb2
 
30ceb2
+echo "\n-- Testing hash_hmac_file() function with bad path --\n";
30ceb2
+hash_hmac_file('crc32', $file.chr(0).$file, $key, TRUE);
30ceb2
+
30ceb2
 ?>
30ceb2
 ===Done===
30ceb2
 --EXPECTF--
30ceb2
@@ -51,4 +54,8 @@ Warning: hash_hmac_file() expects at most 4 parameters, 5 given in %s on line %d
30ceb2
 -- Testing hash_hmac_file() function with invalid hash algorithm --
30ceb2
 
30ceb2
 Warning: hash_hmac_file(): Unknown hashing algorithm: foo in %s on line %d
30ceb2
+
30ceb2
+-- Testing hash_hmac_file() function with bad path --
30ceb2
+
30ceb2
+Warning: hash_hmac_file(): Invalid path in %s on line %d
30ceb2
 ===Done===
30ceb2
\ No newline at end of file
30ceb2
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
30ceb2
index 7af7e8b..23d55cb 100644
30ceb2
--- a/ext/pgsql/pgsql.c
30ceb2
+++ b/ext/pgsql/pgsql.c
30ceb2
@@ -3014,7 +3014,7 @@ PHP_FUNCTION(pg_trace)
30ceb2
 	php_stream *stream;
30ceb2
 	id = PGG(default_link);
30ceb2
 
30ceb2
-	if (zend_parse_parameters(argc TSRMLS_CC, "s|sr", &z_filename, &z_filename_len, &mode, &mode_len, &pgsql_link) == FAILURE) {
30ceb2
+	if (zend_parse_parameters(argc TSRMLS_CC, "p|sr", &z_filename, &z_filename_len, &mode, &mode_len, &pgsql_link) == FAILURE) {
30ceb2
 		return;
30ceb2
 	}
30ceb2
 
30ceb2
diff --git a/ext/standard/link.c b/ext/standard/link.c
30ceb2
index 0e40a0b..4ed2c5e 100644
30ceb2
--- a/ext/standard/link.c
30ceb2
+++ b/ext/standard/link.c
30ceb2
@@ -59,7 +59,7 @@ PHP_FUNCTION(readlink)
30ceb2
 	char buff[MAXPATHLEN];
30ceb2
 	int ret;
30ceb2
 
30ceb2
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &link, &link_len) == FAILURE) {
30ceb2
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &link, &link_len) == FAILURE) {
30ceb2
 		return;
30ceb2
 	}
30ceb2
 
30ceb2
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c
30ceb2
index 7ddfc66..4c2837e 100644
30ceb2
--- a/ext/standard/streamsfuncs.c
30ceb2
+++ b/ext/standard/streamsfuncs.c
30ceb2
@@ -1549,7 +1549,7 @@ PHP_FUNCTION(stream_resolve_include_path)
30ceb2
 	char *filename, *resolved_path;
30ceb2
 	int filename_len;
30ceb2
 
30ceb2
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
30ceb2
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) {
30ceb2
 		return;
30ceb2
 	}
30ceb2
 
30ceb2
diff --git a/ext/xmlwriter/php_xmlwriter.c b/ext/xmlwriter/php_xmlwriter.c
30ceb2
index 206d82a..7a650e2 100644
30ceb2
--- a/ext/xmlwriter/php_xmlwriter.c
30ceb2
+++ b/ext/xmlwriter/php_xmlwriter.c
30ceb2
@@ -1738,7 +1738,7 @@ static PHP_FUNCTION(xmlwriter_write_dtd_entity)
30ceb2
 /* }}} */
30ceb2
 #endif
30ceb2
 
30ceb2
-/* {{{ proto resource xmlwriter_open_uri(resource xmlwriter, string source)
30ceb2
+/* {{{ proto resource xmlwriter_open_uri(string source)
30ceb2
 Create new xmlwriter using source uri for output */
30ceb2
 static PHP_FUNCTION(xmlwriter_open_uri)
30ceb2
 {
30ceb2
@@ -1759,7 +1759,7 @@ static PHP_FUNCTION(xmlwriter_open_uri)
30ceb2
 	void *ioctx;
30ceb2
 #endif
30ceb2
 
30ceb2
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &source, &source_len) == FAILURE) {
30ceb2
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &source, &source_len) == FAILURE) {
30ceb2
 		return;
30ceb2
 	}
30ceb2
 	
30ceb2
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
30ceb2
index d70198c..ec958e1 100644
30ceb2
--- a/ext/zlib/zlib.c
30ceb2
+++ b/ext/zlib/zlib.c
30ceb2
@@ -593,7 +593,7 @@ static PHP_FUNCTION(gzopen)
30ceb2
 	php_stream *stream;
30ceb2
 	long use_include_path = 0;
30ceb2
 
30ceb2
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &filename, &filename_len, &mode, &mode_len, &use_include_path) == FAILURE) {
30ceb2
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ps|l", &filename, &filename_len, &mode, &mode_len, &use_include_path) == FAILURE) {
30ceb2
 		return;
30ceb2
 	}
30ceb2
 
30ceb2
@@ -621,7 +621,7 @@ static PHP_FUNCTION(readgzfile)
30ceb2
 	int size;
30ceb2
 	long use_include_path = 0;
30ceb2
 
30ceb2
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &filename, &filename_len, &use_include_path) == FAILURE) {
30ceb2
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &filename, &filename_len, &use_include_path) == FAILURE) {
30ceb2
 		return;
30ceb2
 	}
30ceb2
 
30ceb2
-- 
30ceb2
2.1.4
30ceb2
30ceb2
From a643ccfb90750e0d830106588d2a46af87706b5b Mon Sep 17 00:00:00 2001
30ceb2
From: Stanislav Malyshev <stas@php.net>
30ceb2
Date: Sun, 12 Apr 2015 20:53:09 -0700
30ceb2
Subject: [PATCH] Fix tests
30ceb2
30ceb2
---
30ceb2
 ext/gd/tests/imageloadfont_error1.phpt    |  6 +++---
30ceb2
 ext/zlib/tests/gzopen_variation1.phpt     | 28 ++++++++++++++--------------
30ceb2
 ext/zlib/tests/readgzfile_variation1.phpt | 10 +++++-----
30ceb2
 ext/zlib/tests/readgzfile_variation6.phpt |  4 ++--
30ceb2
 4 files changed, 24 insertions(+), 24 deletions(-)
30ceb2
30ceb2
diff --git a/ext/gd/tests/imageloadfont_error1.phpt b/ext/gd/tests/imageloadfont_error1.phpt
30ceb2
index 16d1a3c..418bbf3 100644
30ceb2
--- a/ext/gd/tests/imageloadfont_error1.phpt
30ceb2
+++ b/ext/gd/tests/imageloadfont_error1.phpt
30ceb2
@@ -3,7 +3,7 @@ Testing that imageloadfont() breaks on non-string first parameter
30ceb2
 --CREDITS--
30ceb2
 Neveo Harrison <neveoo [at] gmail [dot] com> #testfest #tek11
30ceb2
 --SKIPIF--
30ceb2
-
30ceb2
+
30ceb2
 	if (!extension_loaded("gd")) die("skip GD not present");
30ceb2
 ?>
30ceb2
 --FILE--
30ceb2
@@ -11,5 +11,5 @@ Neveo Harrison <neveoo [at] gmail [dot] com> #testfest #tek11
30ceb2
 var_dump( imageloadfont(array()) );
30ceb2
 ?>
30ceb2
 --EXPECTF--
30ceb2
-Warning: imageloadfont() expects parameter 1 to be string, array given in %s on line %d
30ceb2
-NULL
30ceb2
\ No newline at end of file
30ceb2
+Warning: imageloadfont() expects parameter 1 to be a valid path, array given in %s on line %d
30ceb2
+NULL
30ceb2
diff --git a/ext/zlib/tests/gzopen_variation1.phpt b/ext/zlib/tests/gzopen_variation1.phpt
30ceb2
index c5a47f4..bca48f3 100644
30ceb2
--- a/ext/zlib/tests/gzopen_variation1.phpt
30ceb2
+++ b/ext/zlib/tests/gzopen_variation1.phpt
30ceb2
@@ -1,17 +1,17 @@
30ceb2
 --TEST--
30ceb2
-Test gzopen() function : usage variation 
30ceb2
+Test gzopen() function : usage variation
30ceb2
 --SKIPIF--
30ceb2
-
30ceb2
+
30ceb2
 if (!extension_loaded("zlib")) {
30ceb2
-	print "skip - zlib extension not loaded"; 
30ceb2
-}	 
30ceb2
+	print "skip - zlib extension not loaded";
30ceb2
+}
30ceb2
 ?>
30ceb2
 --FILE--
30ceb2
 
30ceb2
 /* Prototype  : resource gzopen(string filename, string mode [, int use_include_path])
30ceb2
- * Description: Open a .gz-file and return a .gz-file pointer 
30ceb2
+ * Description: Open a .gz-file and return a .gz-file pointer
30ceb2
  * Source code: ext/zlib/zlib.c
30ceb2
- * Alias to functions: 
30ceb2
+ * Alias to functions:
30ceb2
  */
30ceb2
 
30ceb2
 echo "*** Testing gzopen() : usage variation ***\n";
30ceb2
@@ -102,9 +102,9 @@ $inputs = array(
30ceb2
 
30ceb2
       // unset data
30ceb2
       'unset var' => @$unset_var,
30ceb2
-      
30ceb2
+
30ceb2
       // resource variable
30ceb2
-      'resource' => $fp      
30ceb2
+      'resource' => $fp
30ceb2
 );
30ceb2
 
30ceb2
 // loop through each element of the array for filename
30ceb2
@@ -158,19 +158,19 @@ Error: 2 - gzopen(0.5): failed to open stream: No such file or directory, %s(%d)
30ceb2
 bool(false)
30ceb2
 
30ceb2
 --empty array--
30ceb2
-Error: 2 - gzopen() expects parameter 1 to be string, array given, %s(%d)
30ceb2
+Error: 2 - gzopen() expects parameter 1 to be a valid path, array given, %s(%d)
30ceb2
 NULL
30ceb2
 
30ceb2
 --int indexed array--
30ceb2
-Error: 2 - gzopen() expects parameter 1 to be string, array given, %s(%d)
30ceb2
+Error: 2 - gzopen() expects parameter 1 to be a valid path, array given, %s(%d)
30ceb2
 NULL
30ceb2
 
30ceb2
 --associative array--
30ceb2
-Error: 2 - gzopen() expects parameter 1 to be string, array given, %s(%d)
30ceb2
+Error: 2 - gzopen() expects parameter 1 to be a valid path, array given, %s(%d)
30ceb2
 NULL
30ceb2
 
30ceb2
 --nested arrays--
30ceb2
-Error: 2 - gzopen() expects parameter 1 to be string, array given, %s(%d)
30ceb2
+Error: 2 - gzopen() expects parameter 1 to be a valid path, array given, %s(%d)
30ceb2
 NULL
30ceb2
 
30ceb2
 --uppercase NULL--
30ceb2
@@ -210,7 +210,7 @@ Error: 2 - gzopen(Class A object): failed to open stream: No such file or direct
30ceb2
 bool(false)
30ceb2
 
30ceb2
 --instance of classWithoutToString--
30ceb2
-Error: 2 - gzopen() expects parameter 1 to be string, object given, %s(%d)
30ceb2
+Error: 2 - gzopen() expects parameter 1 to be a valid path, object given, %s(%d)
30ceb2
 NULL
30ceb2
 
30ceb2
 --undefined var--
30ceb2
@@ -222,7 +222,7 @@ Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
30ceb2
 bool(false)
30ceb2
 
30ceb2
 --resource--
30ceb2
-Error: 2 - gzopen() expects parameter 1 to be string, resource given, %s(%d)
30ceb2
+Error: 2 - gzopen() expects parameter 1 to be a valid path, resource given, %s(%d)
30ceb2
 NULL
30ceb2
 ===DONE===
30ceb2
 
30ceb2
diff --git a/ext/zlib/tests/readgzfile_variation1.phpt b/ext/zlib/tests/readgzfile_variation1.phpt
30ceb2
index 5a5ec4f..5d9b639 100644
30ceb2
--- a/ext/zlib/tests/readgzfile_variation1.phpt
30ceb2
+++ b/ext/zlib/tests/readgzfile_variation1.phpt
30ceb2
@@ -29,15 +29,15 @@ foreach ( $variation as $var ) {
30ceb2
 ===DONE===
30ceb2
 --EXPECTF--
30ceb2
 
30ceb2
-Warning: readgzfile() expects parameter 1 to be string, array given in %s on line %d
30ceb2
+Warning: readgzfile() expects parameter 1 to be a valid path, array given in %s on line %d
30ceb2
 NULL
30ceb2
 
30ceb2
-Warning: readgzfile() expects parameter 1 to be string, array given in %s on line %d
30ceb2
+Warning: readgzfile() expects parameter 1 to be a valid path, array given in %s on line %d
30ceb2
 NULL
30ceb2
 
30ceb2
-Warning: readgzfile() expects parameter 1 to be string, array given in %s on line %d
30ceb2
+Warning: readgzfile() expects parameter 1 to be a valid path, array given in %s on line %d
30ceb2
 NULL
30ceb2
 
30ceb2
-Warning: readgzfile() expects parameter 1 to be string, array given in %s on line %d
30ceb2
+Warning: readgzfile() expects parameter 1 to be a valid path, array given in %s on line %d
30ceb2
 NULL
30ceb2
-===DONE===
30ceb2
\ No newline at end of file
30ceb2
+===DONE===
30ceb2
diff --git a/ext/zlib/tests/readgzfile_variation6.phpt b/ext/zlib/tests/readgzfile_variation6.phpt
30ceb2
index 702f918..9fcea02 100644
30ceb2
--- a/ext/zlib/tests/readgzfile_variation6.phpt
30ceb2
+++ b/ext/zlib/tests/readgzfile_variation6.phpt
30ceb2
@@ -45,5 +45,5 @@ foreach ( $variation as $var ) {
30ceb2
 --EXPECTF--
30ceb2
 Error: 2 - readgzfile(Class A object): failed to open stream: No such file or directory, %s(%d)
30ceb2
 bool(false)
30ceb2
-Error: 2 - readgzfile() expects parameter 1 to be string, object given, %s(%d)
30ceb2
-NULL
30ceb2
\ No newline at end of file
30ceb2
+Error: 2 - readgzfile() expects parameter 1 to be a valid path, object given, %s(%d)
30ceb2
+NULL
30ceb2
-- 
30ceb2
2.1.4
30ceb2
30ceb2
From 1defbb25ed69e7a1a90e2bcb2ee3b9190ea06577 Mon Sep 17 00:00:00 2001
30ceb2
From: Stanislav Malyshev <stas@php.net>
30ceb2
Date: Sun, 12 Apr 2015 00:56:02 -0700
30ceb2
Subject: [PATCH] Fix test
30ceb2
30ceb2
---
30ceb2
 ext/standard/tests/file/readlink_variation1.phpt | 2 +-
30ceb2
 1 file changed, 1 insertion(+), 1 deletion(-)
30ceb2
30ceb2
diff --git a/ext/standard/tests/file/readlink_variation1.phpt b/ext/standard/tests/file/readlink_variation1.phpt
30ceb2
index 1dae17c..d4f1a5f 100644
30ceb2
--- a/ext/standard/tests/file/readlink_variation1.phpt
30ceb2
+++ b/ext/standard/tests/file/readlink_variation1.phpt
30ceb2
@@ -65,7 +65,7 @@ bool(false)
30ceb2
 Warning: readlink(): %s in %s on line %d
30ceb2
 bool(false)
30ceb2
 
30ceb2
-Warning: readlink() expects parameter 1 to be string, resource given in %s on line %d
30ceb2
+Warning: readlink() expects parameter 1 to be a valid path, resource given in %s on line %d
30ceb2
 NULL
30ceb2
 
30ceb2
 Warning: readlink(): %s in %s on line %d
30ceb2
-- 
30ceb2
2.1.4
30ceb2
30ceb2
From f7d7befae8bcc2db0093f8adaa9f72eeb7ad891e Mon Sep 17 00:00:00 2001
30ceb2
From: Stanislav Malyshev <stas@php.net>
30ceb2
Date: Sun, 31 May 2015 22:47:52 -0700
30ceb2
Subject: [PATCH] Fix #69719 - more checks for nulls in paths
30ceb2
30ceb2
---
30ceb2
 ext/dom/document.c | 22 +++++++++++++++++-----
30ceb2
 ext/gd/gd.c        | 16 ++++++++--------
30ceb2
 2 files changed, 25 insertions(+), 13 deletions(-)
30ceb2
30ceb2
diff --git a/ext/dom/document.c b/ext/dom/document.c
30ceb2
index 48a19dd..097fcba 100644
30ceb2
--- a/ext/dom/document.c
30ceb2
+++ b/ext/dom/document.c
30ceb2
@@ -1760,7 +1760,7 @@ PHP_FUNCTION(dom_document_save)
30ceb2
 	char *file;
30ceb2
 	long options = 0;
30ceb2
 
30ceb2
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l", &id, dom_document_class_entry, &file, &file_len, &options) == FAILURE) {
30ceb2
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Op|l", &id, dom_document_class_entry, &file, &file_len, &options) == FAILURE) {
30ceb2
 		return;
30ceb2
 	}
30ceb2
 
30ceb2
@@ -1990,7 +1990,7 @@ static void _dom_document_schema_validat
30ceb2
 	int                     is_valid;
30ceb2
 	char resolved_path[MAXPATHLEN + 1];
30ceb2
 
30ceb2
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Op|l", &id, dom_document_class_entry, &source, &source_len, &flags) == FAILURE) {
30ceb2
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l", &id, dom_document_class_entry, &source, &source_len, &flags) == FAILURE) {
30ceb2
 		return;
30ceb2
 	}
30ceb2
 
30ceb2
@@ -2003,6 +2003,10 @@ static void _dom_document_schema_validat
30ceb2
 
30ceb2
 	switch (type) {
30ceb2
 	case DOM_LOAD_FILE:
30ceb2
+		if (CHECK_NULL_PATH(source, source_len)) {
30ceb2
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Schema file source");
30ceb2
+			RETURN_FALSE;
30ceb2
+		}
30ceb2
 		valid_file = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN  TSRMLS_CC);
30ceb2
 		if (!valid_file) {
30ceb2
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Schema file source");
30ceb2
@@ -2086,7 +2090,7 @@ static void _dom_document_relaxNG_valida
30ceb2
 	int                     is_valid;
30ceb2
 	char resolved_path[MAXPATHLEN + 1];
30ceb2
 
30ceb2
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Op", &id, dom_document_class_entry, &source, &source_len) == FAILURE) {
30ceb2
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &source, &source_len) == FAILURE) {
30ceb2
 		return;
30ceb2
 	}
30ceb2
 
30ceb2
@@ -2099,6 +2103,10 @@ static void _dom_document_relaxNG_valida
30ceb2
 
30ceb2
 	switch (type) {
30ceb2
 	case DOM_LOAD_FILE:
30ceb2
+		if (CHECK_NULL_PATH(source, source_len)) {
30ceb2
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid RelaxNG file source");
30ceb2
+			RETURN_FALSE;
30ceb2
+		}
30ceb2
 		valid_file = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN  TSRMLS_CC);
30ceb2
 		if (!valid_file) {
30ceb2
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid RelaxNG file source");
30ceb2
@@ -2179,7 +2187,7 @@ static void dom_load_html(INTERNAL_FUNCT
30ceb2
 	
30ceb2
 	id = getThis();
30ceb2
 
30ceb2
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) {
30ceb2
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) {
30ceb2
 		return;
30ceb2
 	}
30ceb2
 
30ceb2
@@ -2189,6 +2197,10 @@ static void dom_load_html(INTERNAL_FUNCT
30ceb2
 	}
30ceb2
 
30ceb2
 	if (mode == DOM_LOAD_FILE) {
30ceb2
+		if (CHECK_NULL_PATH(source, source_len)) {
30ceb2
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid file source");
30ceb2
+			RETURN_FALSE;
30ceb2
+		}
30ceb2
 		ctxt = htmlCreateFileParserCtxt(source, NULL);
30ceb2
 	} else {
30ceb2
 		source_len = xmlStrlen(source);
30ceb2
@@ -2277,7 +2289,7 @@ PHP_FUNCTION(dom_document_save_html_file
30ceb2
 	char *file;
30ceb2
 	const char *encoding;
30ceb2
 
30ceb2
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &file, &file_len) == FAILURE) {
30ceb2
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Op", &id, dom_document_class_entry, &file, &file_len) == FAILURE) {
30ceb2
 		return;
30ceb2
 	}
30ceb2
 
30ceb2
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
30ceb2
index d258c3d..e527575 100644
30ceb2
--- a/ext/gd/gd.c
30ceb2
+++ b/ext/gd/gd.c
30ceb2
@@ -3924,7 +3924,7 @@ PHP_FUNCTION(imagepsloadfont)
30ceb2
 	struct stat st;
30ceb2
 #endif
30ceb2
 
30ceb2
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len) == FAILURE) {
30ceb2
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &file, &file_len) == FAILURE) {
30ceb2
 		return;
30ceb2
 	}
30ceb2
 
30ceb2
-- 
30ceb2
2.1.4
30ceb2
30ceb2
From eee8b6c33fc968ef8c496db8fb54e8c9d9d5a8f9 Mon Sep 17 00:00:00 2001
30ceb2
From: Stanislav Malyshev <stas@php.net>
30ceb2
Date: Tue, 9 Jun 2015 17:11:33 -0700
30ceb2
Subject: [PATCH] fix test
30ceb2
30ceb2
---
30ceb2
 ext/dom/tests/DOMDocument_loadHTMLfile_error2.phpt | 4 ++--
30ceb2
 1 file changed, 2 insertions(+), 2 deletions(-)
30ceb2
30ceb2
diff --git a/ext/dom/tests/DOMDocument_loadHTMLfile_error2.phpt b/ext/dom/tests/DOMDocument_loadHTMLfile_error2.phpt
30ceb2
index 75004e2..e0d0923 100644
30ceb2
--- a/ext/dom/tests/DOMDocument_loadHTMLfile_error2.phpt
30ceb2
+++ b/ext/dom/tests/DOMDocument_loadHTMLfile_error2.phpt
30ceb2
@@ -15,9 +15,9 @@ $result = $doc->loadHTMLFile("");
30ceb2
 assert('$result === false');
30ceb2
 $doc = new DOMDocument();
30ceb2
 $result = $doc->loadHTMLFile("text.html\0something");
30ceb2
-assert('$result === null');
30ceb2
+assert('$result === false');
30ceb2
 ?>
30ceb2
 --EXPECTF--
30ceb2
 %r(PHP ){0,1}%rWarning: DOMDocument::loadHTMLFile(): Empty string supplied as input %s
30ceb2
 
30ceb2
-%r(PHP ){0,1}%rWarning: DOMDocument::loadHTMLFile() expects parameter 1 to be a valid path, string given %s
30ceb2
+%r(PHP ){0,1}%rWarning: DOMDocument::loadHTMLFile(): Invalid file source %s
30ceb2
-- 
30ceb2
2.1.4
30ceb2