Commit | Line | Data |
---|---|---|
70384392 LLB |
1 | From 13f0260beae851f7d5dd96e9ef757d8d6d7daac1 Mon Sep 17 00:00:00 2001 |
2 | From: Mark Adler <madler@alumni.caltech.edu> | |
3 | Date: Sun, 9 Feb 2020 07:20:13 -0800 | |
4 | Subject: [PATCH] Fix false overlapped components detection on 32-bit systems. | |
5 | ||
6 | 32-bit systems with ZIP64_SUPPORT enabled could have different | |
7 | size types for zoff_t and zusz_t. That resulted in bad parameter | |
8 | passing to the bound tracking functions, itself due to the lack of | |
9 | use of C function prototypes in unzip. This commit assures that | |
10 | parameters are cast properly for those calls. | |
11 | ||
12 | This problem occurred only for ill-chosen make options, which give | |
13 | a 32-bit zoff_t. A proper build will result in a zoff_t of 64 bits, | |
14 | even on 32-bit systems. | |
15 | --- | |
16 | extract.c | 7 ++++--- | |
17 | 1 file changed, 4 insertions(+), 3 deletions(-) | |
18 | ||
19 | diff --git a/extract.c b/extract.c | |
20 | index 1b73cb0..d9866f9 100644 | |
21 | --- a/extract.c | |
22 | +++ b/extract.c | |
23 | @@ -329,7 +329,7 @@ static ZCONST char Far OverlappedComponents[] = | |
24 | ||
25 | ||
26 | /* A growable list of spans. */ | |
27 | -typedef zoff_t bound_t; | |
28 | +typedef zusz_t bound_t; | |
29 | typedef struct { | |
30 | bound_t beg; /* start of the span */ | |
31 | bound_t end; /* one past the end of the span */ | |
32 | @@ -518,7 +518,8 @@ int extract_or_test_files(__G) /* return PK-type error code */ | |
33 | return PK_MEM; | |
34 | } | |
35 | if ((G.extra_bytes != 0 && | |
36 | - cover_add((cover_t *)G.cover, 0, G.extra_bytes) != 0) || | |
37 | + cover_add((cover_t *)G.cover, | |
38 | + (bound_t)0, (bound_t)G.extra_bytes) != 0) || | |
39 | (G.ecrec.have_ecr64 && | |
40 | cover_add((cover_t *)G.cover, G.ecrec.ec64_start, | |
41 | G.ecrec.ec64_end) != 0) || | |
42 | @@ -1216,7 +1217,7 @@ static int extract_or_test_entrylist(__G__ numchunk, | |
43 | ||
44 | /* seek_zipf(__G__ pInfo->offset); */ | |
45 | request = G.pInfo->offset + G.extra_bytes; | |
46 | - if (cover_within((cover_t *)G.cover, request)) { | |
47 | + if (cover_within((cover_t *)G.cover, (bound_t)request)) { | |
48 | Info(slide, 0x401, ((char *)slide, | |
49 | LoadFarString(OverlappedComponents))); | |
50 | return PK_BOMB; |