]> granicus.if.org Git - php/commitdiff
Fix #79797: Use of freed hash key in the phar_parse_zipfile function
authorChristoph M. Becker <cmbecker69@gmx.de>
Tue, 14 Jul 2020 15:04:24 +0000 (17:04 +0200)
committerStanislav Malyshev <stas@php.net>
Mon, 3 Aug 2020 08:09:44 +0000 (01:09 -0700)
We must not use heap memory after we freed it.

ext/phar/tests/bug79797.phar [new file with mode: 0644]
ext/phar/tests/bug79797.phpt [new file with mode: 0644]
ext/phar/zip.c

diff --git a/ext/phar/tests/bug79797.phar b/ext/phar/tests/bug79797.phar
new file mode 100644 (file)
index 0000000..21d43d9
Binary files /dev/null and b/ext/phar/tests/bug79797.phar differ
diff --git a/ext/phar/tests/bug79797.phpt b/ext/phar/tests/bug79797.phpt
new file mode 100644 (file)
index 0000000..761e537
--- /dev/null
@@ -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
index e086354b11599fdda7fdced1fc5f54750db11149..b241c0589b4eb35f1c004c7026443272e23fc63e 100644 (file)
@@ -712,7 +712,7 @@ foundit:
                        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;