summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2011-01-30 22:28:57 +0000
committerStanislav Malyshev <stas@php.net>2011-01-30 22:28:57 +0000
commit4a2b458835beb22df12e4398e1b4aa06e4716a8a (patch)
treef5553284e618f628f9293f0aa30603d597e58434 /ext
parent6e57a7792e8143fdf659f597b05e777541afc31f (diff)
downloadphp-git-4a2b458835beb22df12e4398e1b4aa06e4716a8a.tar.gz
fix bug 53885 (ZipArchive segfault with FL_UNCHANGED on empty archive)
Diffstat (limited to 'ext')
-rw-r--r--ext/zip/lib/zip_name_locate.c4
-rw-r--r--ext/zip/tests/bug53885.phpt19
2 files changed, 23 insertions, 0 deletions
diff --git a/ext/zip/lib/zip_name_locate.c b/ext/zip/lib/zip_name_locate.c
index e8b35ff936..96c4f937e0 100644
--- a/ext/zip/lib/zip_name_locate.c
+++ b/ext/zip/lib/zip_name_locate.c
@@ -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
index 0000000000..d59bf8f034
--- /dev/null
+++ b/ext/zip/tests/bug53885.phpt
@@ -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==