20017b
Adapted for 5.4.16 from
20017b
20017b
From 52b93f0cfd3cba7ff98cc5198df6ca4f23865f80 Mon Sep 17 00:00:00 2001
20017b
From: Stanislav Malyshev <stas@php.net>
20017b
Date: Sun, 5 Apr 2015 16:01:24 -0700
20017b
Subject: [PATCH] Fixed bug #69353 (Missing null byte checks for paths in
20017b
 various PHP extensions)
20017b
20017b
---
20017b
 ext/dom/document.c                                 | 5 ++++-
20017b
 ext/dom/tests/DOMDocument_loadHTMLfile_error2.phpt | 5 +++++
20017b
 ext/fileinfo/fileinfo.c                            | 5 +++++
20017b
 ext/fileinfo/tests/finfo_file_basic.phpt           | 4 ++++
20017b
 ext/gd/gd.c                                        | 8 ++++----
20017b
 ext/hash/hash.c                                    | 7 ++++++-
20017b
 ext/hash/tests/hash_hmac_file_error.phpt           | 7 +++++++
20017b
 ext/pgsql/pgsql.c                                  | 2 +-
20017b
 ext/standard/link.c                                | 2 +-
20017b
 ext/standard/streamsfuncs.c                        | 2 +-
20017b
 ext/xmlwriter/php_xmlwriter.c                      | 4 ++--
20017b
 ext/zlib/zlib.c                                    | 4 ++--
20017b
 12 files changed, 42 insertions(+), 13 deletions(-)
20017b
20017b
diff --git a/ext/dom/document.c b/ext/dom/document.c
20017b
index 18c9cc6..7c5817a 100644
20017b
--- a/ext/dom/document.c
20017b
+++ b/ext/dom/document.c
20017b
@@ -1574,6 +1574,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc
20017b
 	xmlInitParser();
20017b
 
20017b
 	if (mode == DOM_LOAD_FILE) {
20017b
+		if (CHECK_NULL_PATH(source, source_len)) {
20017b
+			return NULL;
20017b
+		}
20017b
 		char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN  TSRMLS_CC);
20017b
 		if (file_dest) {
20017b
 			ctxt = xmlCreateFileParserCtxt(file_dest);
20017b
@@ -2165,7 +2165,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */
20017b
 	
20017b
 	id = getThis();
20017b
 
20017b
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) {
20017b
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
 
20017b
diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c
20017b
index ead7585..9f651af 100644
20017b
--- a/ext/fileinfo/fileinfo.c
20017b
+++ b/ext/fileinfo/fileinfo.c
20017b
@@ -506,6 +506,11 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
20017b
 				RETVAL_FALSE;
20017b
 				goto clean;
20017b
 			}
20017b
+			if (CHECK_NULL_PATH(buffer, buffer_len)) {
20017b
+				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid path");
20017b
+				RETVAL_FALSE;
20017b
+				goto clean;
20017b
+			}
20017b
 
20017b
 			wrap = php_stream_locate_url_wrapper(buffer, &tmp2, 0 TSRMLS_CC);
20017b
 
20017b
diff --git a/ext/fileinfo/tests/finfo_file_basic.phpt b/ext/fileinfo/tests/finfo_file_basic.phpt
20017b
index 20223fd..ee70e2e 100644
20017b
--- a/ext/fileinfo/tests/finfo_file_basic.phpt
20017b
+++ b/ext/fileinfo/tests/finfo_file_basic.phpt
20017b
@@ -19,6 +19,7 @@ echo "*** Testing finfo_file() : basic functionality ***\n";
20017b
 var_dump( finfo_file( $finfo, __FILE__) );
20017b
 var_dump( finfo_file( $finfo, __FILE__, FILEINFO_CONTINUE ) );
20017b
 var_dump( finfo_file( $finfo, $magicFile ) );
20017b
+var_dump( finfo_file( $finfo, $magicFile.chr(0).$magicFile) );
20017b
 
20017b
 ?>
20017b
 ===DONE===
20017b
@@ -27,4 +28,7 @@ var_dump( finfo_file( $finfo, $magicFile ) );
20017b
 string(28) "text/x-php; charset=us-ascii"
20017b
 string(22) "PHP script, ASCII text"
20017b
 string(25) "text/plain; charset=utf-8"
20017b
+
20017b
+Warning: finfo_file(): Invalid path in %s/finfo_file_basic.php on line %d
20017b
+bool(false)
20017b
 ===DONE===
20017b
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
20017b
index cbc1d2b..322325e 100644
20017b
--- a/ext/gd/gd.c
20017b
+++ b/ext/gd/gd.c
20017b
@@ -1495,7 +1495,7 @@ PHP_FUNCTION(imageloadfont)
20017b
 	gdFontPtr font;
20017b
 	php_stream *stream;
20017b
 
20017b
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_name) == FAILURE) {
20017b
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &file, &file_name) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
 
20017b
@@ -2438,7 +2438,7 @@ static void _php_image_create_from(INTER
20017b
 	long ignore_warning;
20017b
 #endif
20017b
 	if (image_type == PHP_GDIMG_TYPE_GD2PART) {
20017b
-		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sllll", &file, &file_len, &srcx, &srcy, &width, &height) == FAILURE) {
20017b
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pllll", &file, &file_len, &srcx, &srcy, &width, &height) == FAILURE) {
20017b
 			return;
20017b
 		}
20017b
 		if (width < 1 || height < 1) {
20017b
@@ -2446,7 +2446,7 @@ static void _php_image_create_from(INTER
20017b
 			RETURN_FALSE;
20017b
 		}
20017b
 	} else {
20017b
-		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len) == FAILURE) {
20017b
+		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &file, &file_len) == FAILURE) {
20017b
 			return;
20017b
 		}
20017b
 	}
20017b
@@ -4178,7 +4178,7 @@ PHP_FUNCTION(imagepsencodefont)
20017b
 	char *enc, **enc_vector;
20017b
 	int enc_len, *f_ind;
20017b
 
20017b
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &fnt, &enc, &enc_len) == FAILURE) {
20017b
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rp", &fnt, &enc, &enc_len) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
 
20017b
diff --git a/ext/hash/hash.c b/ext/hash/hash.c
20017b
index abdc62b..9cd6b8e 100644
20017b
--- a/ext/hash/hash.c
20017b
+++ b/ext/hash/hash.c
20017b
@@ -142,6 +142,7 @@ static void php_hash_do_hash(INTERNAL_FU
20017b
 	}
20017b
 	if (isfilename) {
20017b
 		if (CHECK_NULL_PATH(data, data_len)) {
20017b
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid path");
20017b
 			RETURN_FALSE;
20017b
 		}
20017b
 		stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, DEFAULT_CONTEXT);
20017b
@@ -222,6 +223,10 @@ static void php_hash_do_hash_hmac(INTERN
20017b
 		RETURN_FALSE;
20017b
 	}
20017b
 	if (isfilename) {
20017b
+		if (CHECK_NULL_PATH(data, data_len)) {
20017b
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid path");
20017b
+			RETURN_FALSE;
20017b
+		}
20017b
 		stream = php_stream_open_wrapper_ex(data, "rb", REPORT_ERRORS, NULL, DEFAULT_CONTEXT);
20017b
 		if (!stream) {
20017b
 			/* Stream will report errors opening file */
20017b
@@ -449,7 +454,7 @@ PHP_FUNCTION(hash_update_file)
20017b
 	char *filename, buf[1024];
20017b
 	int filename_len, n;
20017b
 
20017b
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|r", &zhash, &filename, &filename_len, &zcontext) == FAILURE) {
20017b
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rp|r", &zhash, &filename, &filename_len, &zcontext) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
 
20017b
diff --git a/ext/hash/tests/hash_hmac_file_error.phpt b/ext/hash/tests/hash_hmac_file_error.phpt
20017b
index 42ab122..26ba8aa 100644
20017b
--- a/ext/hash/tests/hash_hmac_file_error.phpt
20017b
+++ b/ext/hash/tests/hash_hmac_file_error.phpt
20017b
@@ -28,6 +28,9 @@ hash_hmac_file('crc32', $file, $key, TRUE, $extra_arg);
20017b
 echo "\n-- Testing hash_hmac_file() function with invalid hash algorithm --\n";
20017b
 hash_hmac_file('foo', $file, $key, TRUE);
20017b
 
20017b
+echo "\n-- Testing hash_hmac_file() function with bad path --\n";
20017b
+hash_hmac_file('crc32', $file.chr(0).$file, $key, TRUE);
20017b
+
20017b
 ?>
20017b
 ===Done===
20017b
 --EXPECTF--
20017b
@@ -51,4 +54,8 @@ Warning: hash_hmac_file() expects at most 4 parameters, 5 given in %s on line %d
20017b
 -- Testing hash_hmac_file() function with invalid hash algorithm --
20017b
 
20017b
 Warning: hash_hmac_file(): Unknown hashing algorithm: foo in %s on line %d
20017b
+
20017b
+-- Testing hash_hmac_file() function with bad path --
20017b
+
20017b
+Warning: hash_hmac_file(): Invalid path in %s on line %d
20017b
 ===Done===
20017b
\ No newline at end of file
20017b
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
20017b
index 7af7e8b..23d55cb 100644
20017b
--- a/ext/pgsql/pgsql.c
20017b
+++ b/ext/pgsql/pgsql.c
20017b
@@ -2884,7 +2884,7 @@ PHP_FUNCTION(pg_trace)
20017b
 	php_stream *stream;
20017b
 	id = PGG(default_link);
20017b
 	
20017b
-	if (zend_parse_parameters(argc TSRMLS_CC, "s|sr", &z_filename, &z_filename_len, &mode, &mode_len, &pgsql_link) == FAILURE) {
20017b
+	if (zend_parse_parameters(argc TSRMLS_CC, "p|sr", &z_filename, &z_filename_len, &mode, &mode_len, &pgsql_link) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
 
20017b
diff --git a/ext/standard/link.c b/ext/standard/link.c
20017b
index 0e40a0b..4ed2c5e 100644
20017b
--- a/ext/standard/link.c
20017b
+++ b/ext/standard/link.c
20017b
@@ -59,7 +59,7 @@ PHP_FUNCTION(readlink)
20017b
 	char buff[MAXPATHLEN];
20017b
 	int ret;
20017b
 
20017b
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &link, &link_len) == FAILURE) {
20017b
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &link, &link_len) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
 
20017b
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c
20017b
index 7ddfc66..4c2837e 100644
20017b
--- a/ext/standard/streamsfuncs.c
20017b
+++ b/ext/standard/streamsfuncs.c
20017b
@@ -1545,7 +1545,7 @@ PHP_FUNCTION(stream_resolve_include_path)
20017b
 	char *filename, *resolved_path;
20017b
 	int filename_len;
20017b
 
20017b
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) {
20017b
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &filename, &filename_len) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
 
20017b
diff --git a/ext/xmlwriter/php_xmlwriter.c b/ext/xmlwriter/php_xmlwriter.c
20017b
index 206d82a..7a650e2 100644
20017b
--- a/ext/xmlwriter/php_xmlwriter.c
20017b
+++ b/ext/xmlwriter/php_xmlwriter.c
20017b
@@ -1738,7 +1738,7 @@ static PHP_FUNCTION(xmlwriter_write_dtd_entity)
20017b
 /* }}} */
20017b
 #endif
20017b
 
20017b
-/* {{{ proto resource xmlwriter_open_uri(resource xmlwriter, string source)
20017b
+/* {{{ proto resource xmlwriter_open_uri(string source)
20017b
 Create new xmlwriter using source uri for output */
20017b
 static PHP_FUNCTION(xmlwriter_open_uri)
20017b
 {
20017b
@@ -1759,7 +1759,7 @@ static PHP_FUNCTION(xmlwriter_open_uri)
20017b
 	void *ioctx;
20017b
 #endif
20017b
 
20017b
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &source, &source_len) == FAILURE) {
20017b
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &source, &source_len) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
 	
20017b
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
20017b
index d70198c..ec958e1 100644
20017b
--- a/ext/zlib/zlib.c
20017b
+++ b/ext/zlib/zlib.c
20017b
@@ -581,7 +581,7 @@ static PHP_FUNCTION(gzopen)
20017b
 	php_stream *stream;
20017b
 	long use_include_path = 0;
20017b
 
20017b
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &filename, &filename_len, &mode, &mode_len, &use_include_path) == FAILURE) {
20017b
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ps|l", &filename, &filename_len, &mode, &mode_len, &use_include_path) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
 
20017b
@@ -609,7 +609,7 @@ static PHP_FUNCTION(readgzfile)
20017b
 	int size;
20017b
 	long use_include_path = 0;
20017b
 
20017b
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &filename, &filename_len, &use_include_path) == FAILURE) {
20017b
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &filename, &filename_len, &use_include_path) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
 
20017b
-- 
20017b
2.1.4
20017b
20017b
From 1defbb25ed69e7a1a90e2bcb2ee3b9190ea06577 Mon Sep 17 00:00:00 2001
20017b
From: Stanislav Malyshev <stas@php.net>
20017b
Date: Sun, 12 Apr 2015 00:56:02 -0700
20017b
Subject: [PATCH] Fix test
20017b
20017b
---
20017b
 ext/standard/tests/file/readlink_variation1.phpt | 2 +-
20017b
 1 file changed, 1 insertion(+), 1 deletion(-)
20017b
20017b
diff --git a/ext/standard/tests/file/readlink_variation1.phpt b/ext/standard/tests/file/readlink_variation1.phpt
20017b
index 1dae17c..d4f1a5f 100644
20017b
--- a/ext/standard/tests/file/readlink_variation1.phpt
20017b
+++ b/ext/standard/tests/file/readlink_variation1.phpt
20017b
@@ -65,7 +65,7 @@ bool(false)
20017b
 Warning: readlink(): %s in %s on line %d
20017b
 bool(false)
20017b
 
20017b
-Warning: readlink() expects parameter 1 to be string, resource given in %s on line %d
20017b
+Warning: readlink() expects parameter 1 to be a valid path, resource given in %s on line %d
20017b
 NULL
20017b
 
20017b
 Warning: readlink(): %s in %s on line %d
20017b
-- 
20017b
2.1.4
20017b
20017b
From a643ccfb90750e0d830106588d2a46af87706b5b Mon Sep 17 00:00:00 2001
20017b
From: Stanislav Malyshev <stas@php.net>
20017b
Date: Sun, 12 Apr 2015 20:53:09 -0700
20017b
Subject: [PATCH] Fix tests
20017b
20017b
---
20017b
 ext/gd/tests/imageloadfont_error1.phpt    |  6 +++---
20017b
 ext/zlib/tests/gzopen_variation1.phpt     | 28 ++++++++++++++--------------
20017b
 ext/zlib/tests/readgzfile_variation1.phpt | 10 +++++-----
20017b
 ext/zlib/tests/readgzfile_variation6.phpt |  4 ++--
20017b
 4 files changed, 24 insertions(+), 24 deletions(-)
20017b
20017b
diff --git a/ext/gd/tests/imageloadfont_error1.phpt b/ext/gd/tests/imageloadfont_error1.phpt
20017b
index 16d1a3c..418bbf3 100644
20017b
--- a/ext/gd/tests/imageloadfont_error1.phpt
20017b
+++ b/ext/gd/tests/imageloadfont_error1.phpt
20017b
@@ -3,7 +3,7 @@ Testing that imageloadfont() breaks on non-string first parameter
20017b
 --CREDITS--
20017b
 Neveo Harrison <neveoo [at] gmail [dot] com> #testfest #tek11
20017b
 --SKIPIF--
20017b
-
20017b
+
20017b
 	if (!extension_loaded("gd")) die("skip GD not present");
20017b
 ?>
20017b
 --FILE--
20017b
@@ -11,5 +11,5 @@ Neveo Harrison <neveoo [at] gmail [dot] com> #testfest #tek11
20017b
 var_dump( imageloadfont(array()) );
20017b
 ?>
20017b
 --EXPECTF--
20017b
-Warning: imageloadfont() expects parameter 1 to be string, array given in %s on line %d
20017b
-NULL
20017b
\ No newline at end of file
20017b
+Warning: imageloadfont() expects parameter 1 to be a valid path, array given in %s on line %d
20017b
+NULL
20017b
diff --git a/ext/zlib/tests/gzopen_variation1.phpt b/ext/zlib/tests/gzopen_variation1.phpt
20017b
index c5a47f4..bca48f3 100644
20017b
--- a/ext/zlib/tests/gzopen_variation1.phpt
20017b
+++ b/ext/zlib/tests/gzopen_variation1.phpt
20017b
@@ -1,17 +1,17 @@
20017b
 --TEST--
20017b
-Test gzopen() function : usage variation 
20017b
+Test gzopen() function : usage variation
20017b
 --SKIPIF--
20017b
-
20017b
+
20017b
 if (!extension_loaded("zlib")) {
20017b
-	print "skip - zlib extension not loaded"; 
20017b
-}	 
20017b
+	print "skip - zlib extension not loaded";
20017b
+}
20017b
 ?>
20017b
 --FILE--
20017b
 
20017b
 /* Prototype  : resource gzopen(string filename, string mode [, int use_include_path])
20017b
- * Description: Open a .gz-file and return a .gz-file pointer 
20017b
+ * Description: Open a .gz-file and return a .gz-file pointer
20017b
  * Source code: ext/zlib/zlib.c
20017b
- * Alias to functions: 
20017b
+ * Alias to functions:
20017b
  */
20017b
 
20017b
 echo "*** Testing gzopen() : usage variation ***\n";
20017b
@@ -102,9 +102,9 @@ $inputs = array(
20017b
 
20017b
       // unset data
20017b
       'unset var' => @$unset_var,
20017b
-      
20017b
+
20017b
       // resource variable
20017b
-      'resource' => $fp      
20017b
+      'resource' => $fp
20017b
 );
20017b
 
20017b
 // loop through each element of the array for filename
20017b
@@ -158,19 +158,19 @@ Error: 2 - gzopen(0.5): failed to open stream: No such file or directory, %s(%d)
20017b
 bool(false)
20017b
 
20017b
 --empty array--
20017b
-Error: 2 - gzopen() expects parameter 1 to be string, array given, %s(%d)
20017b
+Error: 2 - gzopen() expects parameter 1 to be a valid path, array given, %s(%d)
20017b
 NULL
20017b
 
20017b
 --int indexed array--
20017b
-Error: 2 - gzopen() expects parameter 1 to be string, array given, %s(%d)
20017b
+Error: 2 - gzopen() expects parameter 1 to be a valid path, array given, %s(%d)
20017b
 NULL
20017b
 
20017b
 --associative array--
20017b
-Error: 2 - gzopen() expects parameter 1 to be string, array given, %s(%d)
20017b
+Error: 2 - gzopen() expects parameter 1 to be a valid path, array given, %s(%d)
20017b
 NULL
20017b
 
20017b
 --nested arrays--
20017b
-Error: 2 - gzopen() expects parameter 1 to be string, array given, %s(%d)
20017b
+Error: 2 - gzopen() expects parameter 1 to be a valid path, array given, %s(%d)
20017b
 NULL
20017b
 
20017b
 --uppercase NULL--
20017b
@@ -210,7 +210,7 @@ Error: 2 - gzopen(Class A object): failed to open stream: No such file or direct
20017b
 bool(false)
20017b
 
20017b
 --instance of classWithoutToString--
20017b
-Error: 2 - gzopen() expects parameter 1 to be string, object given, %s(%d)
20017b
+Error: 2 - gzopen() expects parameter 1 to be a valid path, object given, %s(%d)
20017b
 NULL
20017b
 
20017b
 --undefined var--
20017b
@@ -222,7 +222,7 @@ Error: 2 - gzopen(): Filename cannot be empty, %s(%d)
20017b
 bool(false)
20017b
 
20017b
 --resource--
20017b
-Error: 2 - gzopen() expects parameter 1 to be string, resource given, %s(%d)
20017b
+Error: 2 - gzopen() expects parameter 1 to be a valid path, resource given, %s(%d)
20017b
 NULL
20017b
 ===DONE===
20017b
 
20017b
diff --git a/ext/zlib/tests/readgzfile_variation1.phpt b/ext/zlib/tests/readgzfile_variation1.phpt
20017b
index 5a5ec4f..5d9b639 100644
20017b
--- a/ext/zlib/tests/readgzfile_variation1.phpt
20017b
+++ b/ext/zlib/tests/readgzfile_variation1.phpt
20017b
@@ -29,15 +29,15 @@ foreach ( $variation as $var ) {
20017b
 ===DONE===
20017b
 --EXPECTF--
20017b
 
20017b
-Warning: readgzfile() expects parameter 1 to be string, array given in %s on line %d
20017b
+Warning: readgzfile() expects parameter 1 to be a valid path, array given in %s on line %d
20017b
 NULL
20017b
 
20017b
-Warning: readgzfile() expects parameter 1 to be string, array given in %s on line %d
20017b
+Warning: readgzfile() expects parameter 1 to be a valid path, array given in %s on line %d
20017b
 NULL
20017b
 
20017b
-Warning: readgzfile() expects parameter 1 to be string, array given in %s on line %d
20017b
+Warning: readgzfile() expects parameter 1 to be a valid path, array given in %s on line %d
20017b
 NULL
20017b
 
20017b
-Warning: readgzfile() expects parameter 1 to be string, array given in %s on line %d
20017b
+Warning: readgzfile() expects parameter 1 to be a valid path, array given in %s on line %d
20017b
 NULL
20017b
-===DONE===
20017b
\ No newline at end of file
20017b
+===DONE===
20017b
diff --git a/ext/zlib/tests/readgzfile_variation6.phpt b/ext/zlib/tests/readgzfile_variation6.phpt
20017b
index 702f918..9fcea02 100644
20017b
--- a/ext/zlib/tests/readgzfile_variation6.phpt
20017b
+++ b/ext/zlib/tests/readgzfile_variation6.phpt
20017b
@@ -45,5 +45,5 @@ foreach ( $variation as $var ) {
20017b
 --EXPECTF--
20017b
 Error: 2 - readgzfile(Class A object): failed to open stream: No such file or directory, %s(%d)
20017b
 bool(false)
20017b
-Error: 2 - readgzfile() expects parameter 1 to be string, object given, %s(%d)
20017b
-NULL
20017b
\ No newline at end of file
20017b
+Error: 2 - readgzfile() expects parameter 1 to be a valid path, object given, %s(%d)
20017b
+NULL
20017b
-- 
20017b
2.1.4
20017b
20017b
From f7d7befae8bcc2db0093f8adaa9f72eeb7ad891e Mon Sep 17 00:00:00 2001
20017b
From: Stanislav Malyshev <stas@php.net>
20017b
Date: Sun, 31 May 2015 22:47:52 -0700
20017b
Subject: [PATCH] Fix #69719 - more checks for nulls in paths
20017b
20017b
---
20017b
 ext/dom/document.c | 22 +++++++++++++++++-----
20017b
 ext/gd/gd.c        | 16 ++++++++--------
20017b
 2 files changed, 25 insertions(+), 13 deletions(-)
20017b
20017b
diff --git a/ext/dom/document.c b/ext/dom/document.c
20017b
index 48a19dd..097fcba 100644
20017b
--- a/ext/dom/document.c
20017b
+++ b/ext/dom/document.c
20017b
@@ -1754,7 +1754,7 @@ PHP_FUNCTION(dom_document_save)
20017b
 	char *file;
20017b
 	long options = 0;
20017b
 
20017b
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l", &id, dom_document_class_entry, &file, &file_len, &options) == FAILURE) {
20017b
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Op|l", &id, dom_document_class_entry, &file, &file_len, &options) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
 
20017b
@@ -1983,7 +1983,7 @@ static void _dom_document_schema_validat
20017b
 	int                     is_valid;
20017b
 	char resolved_path[MAXPATHLEN + 1];
20017b
 
20017b
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Op", &id, dom_document_class_entry, &source, &source_len) == FAILURE) {
20017b
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &source, &source_len) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
 
20017b
@@ -1996,6 +1996,10 @@ static void _dom_document_schema_validat
20017b
 
20017b
 	switch (type) {
20017b
 	case DOM_LOAD_FILE:
20017b
+		if (CHECK_NULL_PATH(source, source_len)) {
20017b
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Schema file source");
20017b
+			RETURN_FALSE;
20017b
+		}
20017b
 		valid_file = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN  TSRMLS_CC);
20017b
 		if (!valid_file) {
20017b
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Schema file source");
20017b
@@ -2072,7 +2076,7 @@ static void _dom_document_relaxNG_valida
20017b
 	int                     is_valid;
20017b
 	char resolved_path[MAXPATHLEN + 1];
20017b
 
20017b
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Op", &id, dom_document_class_entry, &source, &source_len) == FAILURE) {
20017b
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &source, &source_len) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
 
20017b
@@ -2085,6 +2089,10 @@ static void _dom_document_relaxNG_valida
20017b
 
20017b
 	switch (type) {
20017b
 	case DOM_LOAD_FILE:
20017b
+		if (CHECK_NULL_PATH(source, source_len)) {
20017b
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid RelaxNG file source");
20017b
+			RETURN_FALSE;
20017b
+		}
20017b
 		valid_file = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN  TSRMLS_CC);
20017b
 		if (!valid_file) {
20017b
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid RelaxNG file source");
20017b
@@ -2165,7 +2173,7 @@ static void dom_load_html(INTERNAL_FUNCT
20017b
 	
20017b
 	id = getThis();
20017b
 
20017b
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) {
20017b
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
 
20017b
@@ -2175,6 +2183,10 @@ static void dom_load_html(INTERNAL_FUNCT
20017b
 	}
20017b
 
20017b
 	if (mode == DOM_LOAD_FILE) {
20017b
+		if (CHECK_NULL_PATH(source, source_len)) {
20017b
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid file source");
20017b
+			RETURN_FALSE;
20017b
+		}
20017b
 		ctxt = htmlCreateFileParserCtxt(source, NULL);
20017b
 	} else {
20017b
 		source_len = xmlStrlen(source);
20017b
@@ -2263,7 +2275,7 @@ PHP_FUNCTION(dom_document_save_html_file
20017b
 	char *file;
20017b
 	const char *encoding;
20017b
 
20017b
-	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &file, &file_len) == FAILURE) {
20017b
+	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Op", &id, dom_document_class_entry, &file, &file_len) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
 
20017b
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
20017b
index d258c3d..e527575 100644
20017b
--- a/ext/gd/gd.c
20017b
+++ b/ext/gd/gd.c
20017b
@@ -1790,7 +1790,7 @@ PHP_FUNCTION(imagefilledarc)
20017b
 	long cx, cy, w, h, ST, E, col, style;
20017b
 	gdImagePtr im;
20017b
 	int e, st;
20017b
-	
20017b
+
20017b
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllllllll", &IM, &cx, &cy, &w, &h, &ST, &E, &col, &style) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
@@ -2033,7 +2033,7 @@ PHP_FUNCTION(imagegrabwindow)
20017b
 	if ( handle == 0 ) {
20017b
 		goto clean;
20017b
 	}
20017b
-	pPrintWindow = (tPrintWindow) GetProcAddress(handle, "PrintWindow");  
20017b
+	pPrintWindow = (tPrintWindow) GetProcAddress(handle, "PrintWindow");
20017b
 
20017b
 	if ( pPrintWindow )  {
20017b
 		pPrintWindow(window, memDC, (UINT) client_area);
20017b
@@ -3984,7 +3984,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
20017b
 			if (zend_hash_get_current_data_ex(HASH_OF(EXT), (void **) &item, &pos) == FAILURE) {
20017b
 				continue;
20017b
 			}
20017b
-		
20017b
+
20017b
 			if (strcmp("linespacing", key) == 0) {
20017b
 				convert_to_double_ex(item);
20017b
 				strex.flags |= gdFTEX_LINESPACE;
20017b
@@ -4006,7 +4006,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
20017b
 #endif
20017b
 
20017b
 	PHP_GD_CHECK_OPEN_BASEDIR(fontname, "Invalid font filename");
20017b
-	
20017b
+
20017b
 #ifdef USE_GD_IMGSTRTTF
20017b
 # if HAVE_GD_STRINGFTEX
20017b
 	if (extended) {
20017b
@@ -4071,7 +4071,7 @@ PHP_FUNCTION(imagepsloadfont)
20017b
 	struct stat st;
20017b
 #endif
20017b
 
20017b
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file, &file_len) == FAILURE) {
20017b
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &file, &file_len) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
 
20017b
@@ -4411,11 +4411,11 @@ PHP_FUNCTION(imagepsbbox)
20017b
 	if (argc != 3 && argc != 6) {
20017b
 		ZEND_WRONG_PARAM_COUNT();
20017b
 	}
20017b
-	
20017b
+
20017b
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "srl|lld", &str, &str_len, &fnt, &sz, &sp, &wd, &angle) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
-	
20017b
+
20017b
 	if (argc == 6) {
20017b
 		space = sp;
20017b
 		add_width = wd;
20017b
@@ -4600,7 +4600,7 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
20017b
 #ifdef HAVE_GD_JPG
20017b
     long ignore_warning;
20017b
 #endif
20017b
-	
20017b
+
20017b
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pplll", &f_org, &f_org_len, &f_dest, &f_dest_len, &height, &width, &threshold) == FAILURE) {
20017b
 		return;
20017b
 	}
20017b
-- 
20017b
2.1.4