From 0ff3b772d05489f3b976c692569df64ed8cec2ee Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Tue, 31 Oct 2006 23:25:41 +0000 Subject: [PATCH] - use zip_name_locate in getCommentName --- ext/zip/php_zip.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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); } /* }}} */ -- 2.40.0