Bug #79503 [NEW]: Memory leak on duplicate metadata
| From: | nikic@php.net | Date: | Tue, 21 Apr 2020 09:52:21 +0000 |
| Subject: | Bug #79503 [NEW]: Memory leak on duplicate metadata | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-226699@lists.php.net to get a copy of this message | ||
From: nikic
Operating system:
PHP version: 7.3.17
Package: PHAR related
Bug Type: Bug
Bug description:Memory leak on duplicate metadata
Description:
------------
Passing the file
https://gist.github.com/nikic/5b7a55e6a100c3dedbfd1ac6837c74a9
to
Phar::__construct() results in a memory leak:
#0 0x4ef61d in malloc
(/home/nikic/php-src-fuzz/sapi/fuzzer/php-fuzz-phar+0x4ef61d)
#1 0x105d619 in __zend_malloc
/home/nikic/php-src-fuzz/Zend/zend_alloc.c:2992:14
#2 0xeca559 in zend_string_alloc
/home/nikic/php-src-fuzz/Zend/zend_string.h:141:36
#3 0xeca559 in zend_string_init
/home/nikic/php-src-fuzz/Zend/zend_string.h:163:21
#4 0xecf463 in php_var_unserialize_internal
/home/nikic/php-src-fuzz/ext/standard/var_unserializer.re:953:3
#5 0xeca8ca in php_var_unserialize
/home/nikic/php-src-fuzz/ext/standard/var_unserializer.re:752:11
#6 0xad234e in phar_parse_metadata
/home/nikic/php-src-fuzz/ext/phar/phar.c:621:8
#7 0xa74837 in phar_tar_process_metadata
/home/nikic/php-src-fuzz/ext/phar/tar.c:176:6
#8 0xa74837 in phar_parse_tarfile
/home/nikic/php-src-fuzz/ext/phar/tar.c:512:19
#9 0xad6fdd in phar_open_from_fp
/home/nikic/php-src-fuzz/ext/phar/phar.c:1726:13
#10 0xad4e48 in phar_create_or_parse_filename
/home/nikic/php-src-fuzz/ext/phar/phar.c:1364:7
The cause is a duplicate .phar/.metadata.bin entry, where the second one
overwrites the first without freeing. Probably we should be reporting an
error instead.
Originally from https://github.com/php/php-src/pull/5424.
--
Edit bug report at https://bugs.php.net/bug.php?id=79503&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79503&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79503&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79503&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79503&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79503&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79503&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79503&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79503&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79503&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79503&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79503&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79503&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79503&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79503&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79503&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79503&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79503&r=mysqlcfg