--- embedaddon/php/ext/zip/lib/zip_name_locate.c 2012/02/21 23:48:05 1.1.1.1 +++ embedaddon/php/ext/zip/lib/zip_name_locate.c 2013/07/22 01:32:11 1.1.1.2 @@ -1,6 +1,6 @@ /* zip_name_locate.c -- get index by name - Copyright (C) 1999-2007 Dieter Baron and Thomas Klausner + Copyright (C) 1999-2011 Dieter Baron and Thomas Klausner This file is part of libzip, a library to manipulate ZIP archives. The authors can be contacted at @@ -17,7 +17,7 @@ 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. - + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -55,13 +55,17 @@ _zip_name_locate(struct zip *za, const char *fname, in const char *fn, *p; int i, n; + if (za == NULL) + return -1; + if (fname == NULL) { _zip_error_set(error, ZIP_ER_INVAL, 0); return -1; } - if((flags & ZIP_FL_UNCHANGED) && !za->cdir) { - return -1; + if ((flags & ZIP_FL_UNCHANGED) && za->cdir == NULL) { + _zip_error_set(error, ZIP_ER_NOENT, 0); + return -1; } cmp = (flags & ZIP_FL_NOCASE) ? strcmpi : strcmp; @@ -76,7 +80,7 @@ _zip_name_locate(struct zip *za, const char *fname, in /* newly added (partially filled) entry */ if (fn == NULL) continue; - + if (flags & ZIP_FL_NODIR) { p = strrchr(fn, '/'); if (p)