php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77978 Dirname ending in colon unzips to wrong dir
Submitted: 2019-05-07 08:08 UTC Modified: 2019-10-13 11:08 UTC
From: lars at larsegon dot se Assigned:
Status: Open Package: Zip Related
PHP Version: 7.3.5 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: lars at larsegon dot se
New email:
PHP Version: OS:

 

 [2019-05-07 08:08 UTC] lars at larsegon dot se
Description:
------------
If a directory name in a path for a file in zip archive ends with a colon (:) the file will be extracted to the root dir instead of to its original directory.

Test script:
---------------
<?php

$file = tempnam("/tmp", "ziptest");
$target = tempnam("/tmp", "ziptest");
unlink($target);
mkdir($target);

$zip = new ZipArchive;
$zip->open($file);
$zip->addFromString("dir/test:/filename.txt", "contents");
$zip->addFromString("dir/test:a/filename.txt", "contents");
$zip->addFromString("dir/test/filename.txt", "contents");
$zip->close();

$zip->open($file);
$zip->extractTo($target, "dir/test:/filename.txt");
$zip->extractTo($target, "dir/test:a/filename.txt");
$zip->extractTo($target, "dir/test/filename.txt");
$zip->close();

unlink($file);



Expected result:
----------------
Expected behavior would be that the three files were extracted to the following paths:
/tmp/ziptest/dir/test:/filename.txt
/tmp/ziptest/dir/test:a/filename.txt
/tmp/ziptest/dir/test/filename.txt

Actual result:
--------------
If you run the test script, three files will be extracted to the following paths:
/tmp/ziptest/filename.txt
/tmp/ziptest/dir/test:a/filename.txt
/tmp/ziptest/dir/test/filename.txt

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-21 20:01 UTC] santiagolizardo@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: santiagolizardo
 [2019-05-25 01:34 UTC] konstantin dot kuklin at gmail dot com
The following pull request has been associated:

Patch Name: Fixed bug #77978
On GitHub:  https://github.com/php/php-src/pull/4160
Patch:      https://github.com/php/php-src/pull/4160.patch
 [2019-10-13 11:08 UTC] santiagolizardo@php.net
-Status: Assigned +Status: Open -Assigned To: santiagolizardo +Assigned To:
 [2019-10-20 11:22 UTC] ctrujillopineda at gmail dot com
The following pull request has been associated:

Patch Name: Fixed bug #77978
On GitHub:  https://github.com/php/php-src/pull/4835
Patch:      https://github.com/php/php-src/pull/4835.patch
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Oct 23 02:01:31 2019 UTC