Bug #78641 [NEW]: addGlob modifies value of constant when used in remove_path with trailing slash
| From: | support at hiorg-server dot de | Date: | Mon, 07 Oct 2019 15:08:29 +0000 |
| Subject: | Bug #78641 [NEW]: addGlob modifies value of constant when used in remove_path with trailing slash | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-223119@lists.php.net to get a copy of this message | ||
From: support at hiorg-server dot de
Operating system: Debian GNU/Linux 10 (buster)
PHP version: 7.3.10
Package: Zip Related
Bug Type: Bug
Bug description:addGlob modifies value of constant when used in remove_path with trailing slash
Description:
------------
After adding a file by addGlob using add_path and remove_path options,
the value of the constant used to define the "remove_path" has changed
if it has a trailing slash.
Maybe the code block in line 1604/1605 of php-src/ext/zip/php_zip.c
(https://github.com/php/php-src/blob/4d6f88e2152888e4e4e8ac40c2d4a68d28b6a208/ext/zip/php_zip.c#L1604)
causes this bug since in these lines the "remove_path" will be
modified.
Removing the trailing slash turned out to be a simple workaround for
this issue.
I have used the following Dockerfile to build a docker container with
php7.3.10 to reproduce this bug.
FROM php:7.3.10-cli
RUN apt-get clean
RUN apt-get update
#install some base extensions
RUN apt-get install -y \
libzip-dev \
zip \
&& docker-php-ext-configure zip --with-libzip \
&& docker-php-ext-install zip
Test script:
---------------
<?php
define("TMPDIR", __DIR__ . "/");
$file = 'foo-bar';
touch($file);
$zip = new ZipArchive();
$zip->open("test.zip", ZipArchive::CREATE | ZipArchive::OVERWRITE);
var_dump(TMPDIR);
$zip->addGlob($file, 0, ["remove_path" => TMPDIR]);
var_dump(TMPDIR);
$zip->close();
Expected result:
----------------
string(15) "/usr/src/myapp/"
string(15) "/usr/src/myapp/"
Actual result:
--------------
string(15) "/usr/src/myapp/"
string(15) "/usr/src/myapp"
--
Edit bug report at https://bugs.php.net/bug.php?id=78641&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78641&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78641&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78641&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78641&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78641&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78641&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78641&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78641&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78641&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78641&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78641&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78641&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78641&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78641&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78641&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78641&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78641&r=mysqlcfg