Req #48218 [Com]: ZipArchive->open fails under some circumstances

From: Date: Thu, 15 Feb 2018 11:30:16 +0000
Subject: Req #48218 [Com]: ZipArchive->open fails under some circumstances
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213969@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=48218&edit=1

 ID:                 48218
 Comment by:         mmi at uhb-consulting dot de
 Reported by:        mb at smartftp dot com
 Summary:            ZipArchive->open fails under some circumstances
 Status:             Open
 Type:               Feature/Change Request
 Package:            Zip Related
 Operating System:   *
 PHP Version:        *
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[2010-06-21 10:28:13] pajoye@php.net

Change to feature request, provide a read only mode top open existing archives.

------------------------------------------------------------------------
[2009-07-06 14:37:18] 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.

Regards,
Mat

------------------------------------------------------------------------
[2009-07-06 13:21:07] pajoye@php.net

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-05-10 00:36:24] mb at smartftp dot com

Description:
------------
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:
---------------
<?php

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

$create = new ZipArchive;
if($create->open($file, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE ))
{	
	for($i=0; $i<10; $i++)
	{
		$bogus = "fjewklfj23klfj23lkfj23l";
		$create->addFromString($i, $bogus);
	}
	
	if(!$create->close())
	{
		print("close failed");
	}
}						

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

Expected result:
----------------
ok

Actual result:
--------------
error 11.
content of zip file.


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=48218&edit=1


Thread (9 messages)

« previous php.bugs (#213969) next »