Skip to content

Commit

Permalink
Fix #79797: Use of freed hash key in the phar_parse_zipfile function
Browse files Browse the repository at this point in the history
We must not use heap memory after we freed it.
  • Loading branch information
cmb69 authored and smalyshev committed Aug 2, 2020
1 parent c68d48d commit 7355ab8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Binary file added ext/phar/tests/bug79797.phar
Binary file not shown.
14 changes: 14 additions & 0 deletions ext/phar/tests/bug79797.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Bug #79797 (Use of freed hash key in the phar_parse_zipfile function)
--SKIPIF--
<?php
if (!extension_loaded('phar')) die('skip phar extension not available');
?>
--INI--
phar.cache_list={PWD}/bug79797.phar
--FILE--
<?php
echo "done\n";
?>
--EXPECT--
done
2 changes: 1 addition & 1 deletion ext/phar/zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias,
efree(actual_alias);
}

zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), actual_alias, mydata->alias_len, mydata);
zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), mydata->alias, mydata->alias_len, mydata);
} else {
phar_archive_data *fd_ptr;

Expand Down

0 comments on commit 7355ab8

Please sign in to comment.