Bug #78641 [Opn->Ver]: addGlob modifies value of constant when used in remove_path with trailing slash

From: Date: Mon, 07 Oct 2019 17:09:42 +0000
Subject: Bug #78641 [Opn->Ver]: addGlob modifies value of constant when used in remove_path with trailing slash
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-223123@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78641&edit=1 ID: 78641 Updated by: cmb@php.net Reported by: support at hiorg-server dot de Summary: addGlob modifies value of constant when used in remove_path with trailing slash -Status: Open +Status: Verified Type: Bug Package: Zip Related Operating System: Debian GNU/Linux 10 (buster) PHP Version: 7.3.10 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Indeed! Thanks for reporting. Previous Comments: ------------------------------------------------------------------------ [2019-10-07 15:08:29] support at hiorg-server dot de 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 this bug report at https://bugs.php.net/bug.php?id=78641&edit=1

« previous php.bugs (#223123) next »