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: 2021-09-28 20:27 UTC
From: lars at larsegon dot se Assigned: cmb (profile)
Status: Closed Package: Zip Related
PHP Version: 7.3.5 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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
 [2021-09-28 20:27 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2021-09-29 10:11 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #77978: Dirname ending in colon unzips to wrong dir
On GitHub:  https://github.com/php/php-src/pull/7528
Patch:      https://github.com/php/php-src/pull/7528.patch
 [2021-10-04 10:59 UTC] git@php.net
Automatic comment on behalf of cmb69
Revision: https://github.com/php/php-src/commit/e0c0de003b0812943922dfb51511f3e5c1248f11
Log: Fix #77978: Dirname ending in colon unzips to wrong dir
 [2021-10-04 10:59 UTC] git@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 19:01:28 2024 UTC