php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53893 Wrong return value for ZipArchive::extractTo()
Submitted: 2011-01-31 17:49 UTC Modified: 2011-02-07 17:20 UTC
From: schmale at froglogic dot com Assigned: pajoye (profile)
Status: Closed Package: Zip Related
PHP Version: 5.3.5 OS: Linux
Private report: No CVE-ID: None
 [2011-01-31 17:49 UTC] schmale at froglogic dot com
Description:
------------
PHP version (as given in phpinfo()): PHP Version 5.3.3-1ubuntu9.3

Zip-related information:
Zip 	enabled
Extension Version 	$Id: php_zip.c 300470 2010-06-15 18:48:33Z pajoye $
Zip version 	1.9.1
Libzip version 	0.9.0 

Test script:
---------------
function testReturnValue() {
        $extractToPath = "/home/user/testDir"; /* existing dir with NO write privileges */
        $zipPath = "path/to/zipFile"; // has to be valid zip file

        $zip = new ZipArchive();
        $open = $zip->open($zipPath);
        if ($open === true) {
           $extracting = $zip->extractTo($extractToPath);
           $zip->close();
           return $extracting;
        } else {
           return false;
        }
}

Expected result:
----------------
Return value of testReturnValue() should be FALSE, as long as the php user has no write access to the directory into which we extract the zip (because if that's the case, nothing will happen).

Actual result:
--------------
Return value is TRUE, even if no extracting happened due to lacking privileges.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-31 21:36 UTC] felipe@php.net
-Status: Open +Status: Feedback
 [2011-01-31 21:36 UTC] felipe@php.net
Hello, I've a doubt about the test case. $zipPath points to an empty zip file?
 [2011-02-01 08:57 UTC] schmale at froglogic dot com
-Status: Feedback +Status: Open
 [2011-02-01 08:57 UTC] schmale at froglogic dot com
No, it's just an arbitrary zip file. Not empty, of course. In my case, it was a zip file of approx. 50kb size.

If I deleted the existing directory, the zip file was extracted perfectly. However, extracting the zip file into a directory with no write privileges did nothing at all. This is desired behaviour, of course, if it wasn't for the return value: The ZipArchive::extractTo's return value was TRUE either way, which lead to some confusion.
 [2011-02-07 17:20 UTC] pajoye@php.net
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&revision=308107
Log: - Fixed bug #53893 (Wrong return value for ZipArchive::extractTo())
 [2011-02-07 17:20 UTC] pajoye@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: pajoye
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 10:01:29 2024 UTC