Skip to content

Commit

Permalink
check rootseek after correction #41
Browse files Browse the repository at this point in the history
  • Loading branch information
gdraheim committed Mar 13, 2018
1 parent 1ba660b commit 19c9e4d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions zzip/zip.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
* Author:
* Guido Draheim <guidod@gmx.de>
Expand Down Expand Up @@ -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)

This comment has been minimized.

Copy link
@ret2libc

ret2libc Mar 15, 2018

I guess this should be zz_rootsize

return ZZIP_CORRUPTED;

hdr0 = (struct zzip_dir_hdr *) malloc(zz_rootsize);
if (! hdr0)
return ZZIP_DIRSIZE;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 19c9e4d

Please sign in to comment.