Skip to content

Commit 706c502

Browse files
committed
parse_root_dir: Verify size of extra obtained
* Fix the issue gdraheim#164 where extra_ptr could be alocated without enough bytes to check the magic value. Signed-off-by: vlefebvre <[email protected]>
1 parent c862f96 commit 706c502

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

zzip/zip.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,8 @@ __zzip_parse_root_directory(int fd, struct _disk_trailer* trailer, struct zzip_d
525525
hdr->d_namlen = u_namlen;
526526

527527
/* looking for ZIP64 extras when csize on intmax */
528-
if (u_extras && (hdr->d_csize & 0xFFFFu == 0xFFFFu)) {
528+
if (u_extras >= __sizeof(struct zzip_extra_zip64) &&\
529+
(hdr->d_csize & 0xFFFFu == 0xFFFFu)) {
529530
DBG3("%i extras bytes (%i)", u_extras, sizeof(struct zzip_extra_zip64));
530531
zzip_off64_t zz_extras = zz_offset + sizeof(*d) + u_namlen;
531532
zzip_byte_t* extras_ptr;

0 commit comments

Comments
 (0)