From 0eb5a95102cd512089537ce4257b2a8430a54e64 Mon Sep 17 00:00:00 2001 From: Guido Draheim Date: Thu, 8 Aug 2024 21:37:10 +0200 Subject: [PATCH] partial revert on #169 --- zzip/zip.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zzip/zip.c b/zzip/zip.c index 1593bcde..d6640e02 100644 --- a/zzip/zip.c +++ b/zzip/zip.c @@ -526,8 +526,12 @@ __zzip_parse_root_directory(int fd, struct _disk_trailer* trailer, struct zzip_d hdr->d_name[u_namlen] = '\0'; hdr->d_namlen = u_namlen; + /* there are some zip files around that do not encode the diskstart field, + so the actual zzip_extras_zip64 block is a bit shorter */ +#define __sizeof_z_diskstart64 4 /* looking for ZIP64 extras when csize on intmax */ - if (u_extras >= sizeof(struct zzip_extra_zip64) && (hdr->d_csize & 0xFFFFu == 0xFFFFu)) { + if (u_extras >= (sizeof(struct zzip_extra_zip64) - __sizeof_z_diskstart64) && + (hdr->d_csize & 0xFFFFu == 0xFFFFu)) { DBG3("%i extras bytes (%i)", u_extras, sizeof(struct zzip_extra_zip64)); zzip_off64_t zz_extras = zz_offset + sizeof(*d) + u_namlen; zzip_byte_t* extras_ptr;