]> granicus.if.org Git - php/commitdiff
fix bug 53885 (ZipArchive segfault with FL_UNCHANGED on empty archive)
authorStanislav Malyshev <stas@php.net>
Sun, 30 Jan 2011 22:28:57 +0000 (22:28 +0000)
committerStanislav Malyshev <stas@php.net>
Sun, 30 Jan 2011 22:28:57 +0000 (22:28 +0000)
NEWS
ext/zip/lib/zip_name_locate.c
ext/zip/tests/bug53885.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 7a52ee4e7522cd7b3d9eaa52e6ae4ca84794bd99..032190a35513a243f7cf57e91aade1b60f385ab6 100644 (file)
--- a/NEWS
+++ b/NEWS
   . Fixed bug #53603 (ZipArchive should quiet stat errors). (brad dot froehle at
     gmail dot com, Gustavo)
   . Fixed bug #53854 (Missing constants for compression type). (Richard, Adam)
+  . Fixed bug #53885 (ZipArchive segfault with FL_UNCHANGED on empty archive).
+    (Stas, Maksymilian Arciemowicz).
 
 06 Jan 2011, PHP 5.3.5
 - Fixed Bug #53632 (infinite loop with x87 fpu). (CVE-2010-4645) (Scott, 
index e8b35ff936ecd04a85eb7da86e8e27613d468c12..96c4f937e0540ddeb9d7b6523e53ffc44db8d8bd 100644 (file)
@@ -60,6 +60,10 @@ _zip_name_locate(struct zip *za, const char *fname, int flags,
        return -1;
     }
 
+    if((flags & ZIP_FL_UNCHANGED)  && !za->cdir) {
+       return -1;
+    }
+
     cmp = (flags & ZIP_FL_NOCASE) ? strcmpi : strcmp;
 
     n = (flags & ZIP_FL_UNCHANGED) ? za->cdir->nentry : za->nentry;
diff --git a/ext/zip/tests/bug53885.phpt b/ext/zip/tests/bug53885.phpt
new file mode 100644 (file)
index 0000000..d59bf8f
--- /dev/null
@@ -0,0 +1,19 @@
+--TEST--
+Bug #53885 (ZipArchive segfault with FL_UNCHANGED on empty archive)
+--SKIPIF--
+<?php
+if(!extension_loaded('zip')) die('skip');
+?>
+--FILE--
+<?php
+$fname = dirname(__FILE__)."/test53885.zip";
+if(file_exists($fname)) unlink($fname);
+touch($fname);
+$nx=new ZipArchive();
+$nx->open($fname);
+$nx->locateName("a",ZIPARCHIVE::FL_UNCHANGED);
+$nx->statName("a",ZIPARCHIVE::FL_UNCHANGED);
+?>
+==DONE==
+--EXPECTF--
+==DONE==