]> granicus.if.org Git - zziplib/commitdiff
check rootseek after correction #41
authorGuido Draheim <guidod@gmx.de>
Tue, 13 Mar 2018 00:50:36 +0000 (01:50 +0100)
committerGuido Draheim <guidod@gmx.de>
Tue, 13 Mar 2018 00:50:36 +0000 (01:50 +0100)
zzip/zip.c

index 6be8d7c8f944bbf4aece8cc5f164c45933227669..0d79d5298860e1b1543f4dbd42c3a9862f8e2d8f 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Author:
  *      Guido Draheim <guidod@gmx.de>
@@ -422,6 +421,9 @@ __zzip_parse_root_directory(int fd,
     zzip_off64_t zz_rootseek = _disk_trailer_rootseek(trailer);
     __correct_rootseek(zz_rootseek, zz_rootsize, trailer);
 
+    if (zz_entries < 0 || zz_rootseek < 0 || zz_rootseek < 0)
+        return ZZIP_CORRUPTED;
+
     hdr0 = (struct zzip_dir_hdr *) malloc(zz_rootsize);
     if (! hdr0)
         return ZZIP_DIRSIZE;
@@ -465,8 +467,9 @@ __zzip_parse_root_directory(int fd,
 #     endif
 
         if (fd_map)
-            { d = (void*)(fd_map+zz_fd_gap+zz_offset); } /* fd_map+fd_gap==u_rootseek */
-        else
+        {
+            d = (void*)(fd_map+zz_fd_gap+zz_offset); /* fd_map+fd_gap==u_rootseek */
+        } else
         {
             if (io->fd.seeks(fd, zz_rootseek + zz_offset, SEEK_SET) < 0)
                 return ZZIP_DIR_SEEK;