|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #48218 ZipArchive->open fails under some circumstances
Submitted: 2009-05-10 00:36 UTC Modified: 2021-07-02 15:44 UTC
Avg. Score:3.5 ± 0.9
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mb at smartftp dot com Assigned: cmb (profile)
Status: Closed Package: Zip Related
PHP Version: * OS: *
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.
Bug Type:
From: mb at smartftp dot com
New email:
PHP Version: OS:


 [2009-05-10 00:36 UTC] mb at smartftp dot com
The ZIPArchive->open fails with error 11 when a zip file is opened that has just been created using ZIPArchive. 
The test code works as expected when running it under administrative privileges. However when running it under restricted access privileges the ZIPArchive->open function is unable to open the file. On the other side readfile() can successfully open the same file. My guess is that the ZipArchive->open functions tries to open the file using a mode other than just read.

Reproduce code:

$file = tempnam(sys_get_temp_dir(), 'zip');
print($file . "\n");

$create = new ZipArchive;
	for($i=0; $i<10; $i++)
		$bogus = "fjewklfj23klfj23lkfj23l";
		$create->addFromString($i, $bogus);
		print("close failed");

$zip = new ZipArchive();
$open = $zip->open($file);
if($open === TRUE)
	print("error ".$open."\n");

Expected result:

Actual result:
error 11.
content of zip file.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-06 13:21 UTC]
It open the files in read/write mode.

What do you mean by restricted privileges? Can you describe the exact situation when you get this error (which permissions, context, etc.)?
 [2009-07-06 14:37 UTC] mb at smartftp dot com
Restricted privileges: read only access

If the open() function really requires rw access consider to fall back to read-only "r" if read-write "rw" fails. This way the archive can be opened for read only access.

 [2010-06-21 10:28 UTC]
-Type: Bug +Type: Feature/Change Request -PHP Version: 5.*, 6CVS (2009-05-10) +PHP Version: *
 [2010-06-21 10:28 UTC]
Change to feature request, provide a read only mode top open existing archives.
 [2017-10-24 07:31 UTC]
-Status: Assigned +Status: Open -Assigned To: pajoye +Assigned To:
 [2018-02-15 11:30 UTC] mmi at uhb-consulting dot de
I found out ZIPArchive crashes wiht no message when creating Zip Files with file Paths greater than 260 chars on Windows. maybe unchecked Buffer.
 [2021-07-02 15:44 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-07-02 15:44 UTC]
ZipArchive::RDONLY is available as of PHP 7.4.3 for libzip ≥

> I found out ZIPArchive crashes wiht no message when creating Zip
> Files with file Paths greater than 260 chars on Windows. maybe
> unchecked Buffer.

I can't reproduce.  Please open a new bug report with a reproduce
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Jul 27 12:01:23 2021 UTC