php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64775 ZipArchive::close returns false and handle is not removed on zip file
Submitted: 2013-05-04 15:57 UTC Modified: 2013-05-04 16:43 UTC
From: imprec at gmail dot com Assigned:
Status: Not a bug Package: zip (PECL)
PHP Version: 5.5.0beta4 OS: Ubuntu
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
10 + 11 = ?
Subscribe to this entry?

 
 [2013-05-04 15:57 UTC] imprec at gmail dot com
Description:
------------
On PHP 5.5, when creating an archive with either ZIPARCHIVE::CREATE or 
ZIPARCHIVE::OVERWRITE, then adding a file and finally closing it, the close method 
returns false and the handle on the zip file is not closed.

So, if you try to chmod your zip file after that, it will fail.

Test script:
---------------
Here is a standard code that reproduce the bug :

if (file_exists('test.zip')) {
    unlink('test.zip');
}

$zip = new ZipArchive();

var_dump($zip->open('test.zip', ZIPARCHIVE::CREATE));
var_dump($zip->addFile(__FILE__, 'script.php'));
var_dump($zip->close());

var_dump(@chmod('test.zip', 0760));


The bug is visible on travis : https://travis-ci.org/romainneutron/travis-tests/jobs/6881256 with the PHPUnit script : https://github.com/romainneutron/travis-tests/blob/master/tests/Tests/ZipTest.php



Expected result:
----------------
bool(true)
bool(true)
bool(true)
bool(true)

Actual result:
--------------
bool(true)
bool(true)
bool(false)
bool(false)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-04 16:13 UTC] imprec at gmail dot com
-Status: Open +Status: Closed
 [2013-05-04 16:13 UTC] imprec at gmail dot com
Actually the error happen on php 5.5.0 beta 1 and seems solved on PHP 5.5.0 beta 
4, sorry
 [2013-05-04 16:43 UTC] pajoye@php.net
-Status: Closed +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 11:01:30 2024 UTC