]> granicus.if.org Git - php/commitdiff
- use zip_name_locate in getCommentName
authorPierre Joye <pajoye@php.net>
Tue, 31 Oct 2006 23:25:41 +0000 (23:25 +0000)
committerPierre Joye <pajoye@php.net>
Tue, 31 Oct 2006 23:25:41 +0000 (23:25 +0000)
ext/zip/php_zip.c

index 3b6d64888d93cb25a1a7336fcc85ec5ed0a0eca9..1c582ed3a0d5b48aa5acbe306264804fcdaacee0 100644 (file)
@@ -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);
 }
 /* }}} */