]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix the potential for a buffer underflow.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sun, 2 Dec 2012 11:30:49 +0000 (20:30 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Sun, 2 Dec 2012 11:30:49 +0000 (20:30 +0900)
libarchive/archive_write_set_format_zip.c

index 974fd67e482a965cad17623ed5955e6affa4543b..3d8b3b5f9ca7237ca55fdc5746d5c60dae392c2b 100644 (file)
@@ -893,7 +893,8 @@ path_length(struct archive_entry *entry)
 
        if (path == NULL)
                return (0);
-       if ((type == AE_IFDIR) & (path[strlen(path) - 1] != '/')) {
+       if (type == AE_IFDIR &&
+           (path[0] == '\0' || path[strlen(path) - 1] != '/')) {
                return strlen(path) + 1;
        } else {
                return strlen(path);