Skip to content

Commit

Permalink
Merge pull request #170 from keentux/disk-trailer-size
Browse files Browse the repository at this point in the history
fetch_disk_trailer: Don't truncate the size verif
  • Loading branch information
gdraheim authored Aug 7, 2024
2 parents a7a4502 + 2a84ae7 commit 7a65df0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions zzip/zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ __zzip_fetch_disk_trailer(int fd, zzip_off_t filesize, struct _disk_trailer* _zz
register unsigned char* tail;
for (tail = end - 1; (tail >= mapped); tail--) {
if ((*tail == 'P') && /* quick pre-check for trailer magic */
end - tail >= __sizeof(struct zzip_disk_trailer) - 2 &&
end - tail >= __sizeof(struct zzip_disk_trailer) &&
zzip_disk_trailer_check_magic(tail)) {
#ifndef ZZIP_DISK64_TRAILER
/* if the file-comment is not present, it happens
Expand Down Expand Up @@ -328,7 +328,7 @@ __zzip_fetch_disk_trailer(int fd, zzip_off_t filesize, struct _disk_trailer* _zz
return (0);
}
}
else if ((*tail == 'P') && end - tail >= __sizeof(struct zzip_disk64_trailer) - 2 &&
else if ((*tail == 'P') && end - tail >= __sizeof(struct zzip_disk64_trailer) &&
zzip_disk64_trailer_check_magic(tail)) {
#ifndef ZZIP_DISK64_TRAILER
return (ZZIP_DIR_LARGEFILE);
Expand Down

0 comments on commit 7a65df0

Please sign in to comment.