From: Pierre Joye Date: Tue, 31 Oct 2006 23:25:41 +0000 (+0000) Subject: - use zip_name_locate in getCommentName X-Git-Tag: RELEASE_1_0_0RC1~1163 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ff3b772d05489f3b976c692569df64ed8cec2ee;p=php - use zip_name_locate in getCommentName --- diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 3b6d64888d..1c582ed3a0 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -1306,6 +1306,10 @@ ZIPARCHIVE_METHOD(setCommentName) return; } + if (name_len < 1) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Empty string as entry name"); + } + idx = zip_name_locate(intern, name, 0); if (idx < 0) { RETURN_FALSE; @@ -1347,12 +1351,11 @@ ZIPARCHIVE_METHOD(getCommentName) { struct zip *intern; zval *this = getThis(); - int name_len; + int name_len, idx; long flags = 0; int comment_len = 0; const char * comment; char *name; - struct zip_stat sb; if (!this) { RETURN_FALSE; @@ -1365,8 +1368,17 @@ ZIPARCHIVE_METHOD(getCommentName) return; } - PHP_ZIP_STAT_PATH(intern, name, name_len, 0, sb); - comment = zip_get_file_comment(intern, sb.index, &comment_len, (int)flags); + if (name_len < 1) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Empty string as entry name"); + RETURN_FALSE; + } + + idx = zip_name_locate(intern, name, 0); + if (idx < 0) { + RETURN_FALSE; + } + + comment = zip_get_file_comment(intern, idx, &comment_len, (int)flags); RETURN_STRINGL((char *)comment, (long)comment_len, 1); } /* }}} */