Bug #81490 [NEW]: ZipArchive::extractTo() may leak memory
| From: | cmb@php.net | Date: | Thu, 30 Sep 2021 11:44:35 +0000 |
| Subject: | Bug #81490 [NEW]: ZipArchive::extractTo() may leak memory | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-236934@lists.php.net to get a copy of this message | ||
From: cmb
Operating system: *
PHP version: 7.4Git-2021-09-30 (Git)
Package: Zip Related
Bug Type: Bug
Bug description:ZipArchive::extractTo() may leak memory
Description:
------------
ZIP archives may contain files with an empty filename[1]:
| If input came from standard input, the file name length is set
| to zero.
If such a file is extracted, there is a memory leak. The same
happens whenever virtual_file_ex() fails for the given filename,
for whatever reason.
[1] <https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT>
section 4.4.12
Test script:
---------------
<?php
$zip = new ZipArchive();
$zip->open(__DIR__ . "/test.zip",
ZipArchive::CREATE|ZipArchive::OVERWRITE);
$zip->addFromString("", "yada yada");
mkdir(__DIR__ . "/extract");
$zip->open(__DIR__ . "/test.zip");
$zip->extractTo(__DIR__ . "/extract", "");
?>
Actual result:
--------------
[Thu Sep 30 13:42:44 2021] Script:
'C:\php-sdk\phpdev\vc15\x64\zip1.php'
ext\zip\php_zip.c(154) : Freeing 0x0000023abbe88000 (1 bytes),
script=C:\php-sdk\phpdev\vc15\x64\zip1.php
=== Total 1 memory leaks detected ===
--
Edit bug report at https://bugs.php.net/bug.php?id=81490&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81490&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81490&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81490&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81490&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81490&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81490&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81490&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81490&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81490&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81490&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81490&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81490&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81490&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81490&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81490&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81490&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81490&r=mysqlcfg