From 19c9e4dc6c5cf92a38d0d23dbccac6993f9c41be Mon Sep 17 00:00:00 2001 From: Guido Draheim Date: Tue, 13 Mar 2018 01:50:36 +0100 Subject: [PATCH] check rootseek after correction #41 --- zzip/zip.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/zzip/zip.c b/zzip/zip.c index 6be8d7c..0d79d52 100644 --- a/zzip/zip.c +++ b/zzip/zip.c @@ -1,4 +1,3 @@ - /* * Author: * Guido Draheim @@ -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; -- 2.40.0