]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
zip: Improve bid for huge EOCDs (#2159)
authorTobias Stoeckmann <stoeckmann@users.noreply.github.com>
Fri, 3 May 2024 22:18:34 +0000 (00:18 +0200)
committerGitHub <noreply@github.com>
Fri, 3 May 2024 22:18:34 +0000 (15:18 -0700)
Cast any of cd_offset or cd_size to int64_t to avoid truncation of
result because both variables are of type uint32_t.

The calculation happens before comparison with current_offset, so it is
not automatically expanded to int64_t during calculation.

libarchive/archive_read_support_format_zip.c

index c9759eaf9a898b1e5ac6c414647914ab582699b2..ac80a99ad9cb4ad11876631abafe2291b77325c1 100644 (file)
@@ -3680,7 +3680,7 @@ read_eocd(struct zip *zip, const char *p, int64_t current_offset)
        if (archive_le16dec(p + 10) != archive_le16dec(p + 8))
                return 0;
        /* Central directory can't extend beyond start of EOCD record. */
-       if (cd_offset + cd_size > current_offset)
+       if ((int64_t)cd_offset + cd_size > current_offset)
                return 0;
 
        /* Save the central directory location for later use. */