Skip to content

Commit

Permalink
Merge branch 'PHP-5.6' into PHP-7.0
Browse files Browse the repository at this point in the history
* PHP-5.6:
  fix memory leak
  FIx bug #70433 - Uninitialized pointer in phar_make_dirstream when zip entry filename is "/"

Conflicts:
	ext/phar/dirstream.c
  • Loading branch information
smalyshev committed Sep 29, 2015
2 parents e7574a5 + 51b23cd commit 4c6f486
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ext/phar/dirstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest) /* {{{ */
zend_hash_internal_pointer_reset(manifest);

while (FAILURE != zend_hash_has_more_elements(manifest)) {
if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key(manifest, &str_key, &unused)) {
if (HASH_KEY_IS_STRING != zend_hash_get_current_key(manifest, &str_key, &unused)) {
break;
}

Expand Down
23 changes: 23 additions & 0 deletions ext/phar/tests/bug70433.phpt
Original file line number Diff line number Diff line change
@@ -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
Binary file added ext/phar/tests/bug70433.zip
Binary file not shown.
1 change: 1 addition & 0 deletions ext/phar/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ int phar_get_entry_data(phar_entry_data **ret, char *fname, int fname_len, char
if (entry->link) {
phar_entry_info *link = phar_get_link_source(entry);
if(!link) {
efree(*ret);
return FAILURE;
}
(*ret)->zero = phar_get_fp_offset(link);
Expand Down

0 comments on commit 4c6f486

Please sign in to comment.