summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2015-09-28 20:44:28 -0700
committerFerenc Kovacs <tyrael@php.net>2015-09-30 01:31:53 +0200
commit752e4c6c07aee71dbb6f277cc41a417e025e9f9e (patch)
tree40220f3cf9654af4bccdc4cc2e34a26c51cb6773
parent791a49ac7ad24dfab83bde7730bffd4a4354c8df (diff)
downloadphp-git-752e4c6c07aee71dbb6f277cc41a417e025e9f9e.tar.gz
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5: fix memory leak FIx bug #70433 - Uninitialized pointer in phar_make_dirstream when zip entry filename is "/" Conflicts: ext/phar/dirstream.c
-rw-r--r--ext/phar/dirstream.c2
-rw-r--r--ext/phar/tests/bug70433.phpt23
-rwxr-xr-xext/phar/tests/bug70433.zipbin0 -> 264 bytes
-rw-r--r--ext/phar/util.c1
4 files changed, 25 insertions, 1 deletions
diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c
index e863509b6c..e6926ce154 100644
--- a/ext/phar/dirstream.c
+++ b/ext/phar/dirstream.c
@@ -198,7 +198,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
zend_hash_internal_pointer_reset(manifest);
while (FAILURE != zend_hash_has_more_elements(manifest)) {
- if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(manifest, &str_key, &keylen, &unused, 0, NULL)) {
+ if (HASH_KEY_IS_STRING != zend_hash_get_current_key_ex(manifest, &str_key, &keylen, &unused, 0, NULL)) {
break;
}
diff --git a/ext/phar/tests/bug70433.phpt b/ext/phar/tests/bug70433.phpt
new file mode 100644
index 0000000000..cbebb34c37
--- /dev/null
+++ b/ext/phar/tests/bug70433.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Phar - bug #70433 - Uninitialized pointer in phar_make_dirstream when zip entry filename is "/"
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+$phar = new PharData(__DIR__."/bug70433.zip");
+var_dump($phar);
+$meta = $phar->getMetadata();
+var_dump($meta);
+?>
+DONE
+--EXPECTF--
+object(PharData)#1 (3) {
+ ["pathName":"SplFileInfo":private]=>
+ string(0) ""
+ ["glob":"DirectoryIterator":private]=>
+ bool(false)
+ ["subPathName":"RecursiveDirectoryIterator":private]=>
+ string(0) ""
+}
+NULL
+DONE
diff --git a/ext/phar/tests/bug70433.zip b/ext/phar/tests/bug70433.zip
new file mode 100755
index 0000000000..3994a30a8e
--- /dev/null
+++ b/ext/phar/tests/bug70433.zip
Binary files differ
diff --git a/ext/phar/util.c b/ext/phar/util.c
index fb3c8beac7..461cbf91f1 100644
--- a/ext/phar/util.c
+++ b/ext/phar/util.c
@@ -496,6 +496,7 @@ really_get_entry:
if (entry->link) {
phar_entry_info *link = phar_get_link_source(entry TSRMLS_CC);
if(!link) {
+ efree(*ret);
return FAILURE;
}
(*ret)->zero = phar_get_fp_offset(link TSRMLS_CC);