]> git.ipfire.org Git - ipfire-3.x.git/blob - unzip/patches/unzip-6.0-cve-2014-8141.patch
json-c: Update to version 0.17-20230812
[ipfire-3.x.git] / unzip / patches / unzip-6.0-cve-2014-8141.patch
1 diff --git a/fileio.c b/fileio.c
2 index 03fc4be..2a61a30 100644
3 --- a/fileio.c
4 +++ b/fileio.c
5 @@ -176,6 +176,8 @@ static ZCONST char Far FilenameTooLongTrunc[] =
6 #endif
7 static ZCONST char Far ExtraFieldTooLong[] =
8 "warning: extra field too long (%d). Ignoring...\n";
9 +static ZCONST char Far ExtraFieldCorrupt[] =
10 + "warning: extra field (type: 0x%04x) corrupt. Continuing...\n";
11
12 #ifdef WINDLL
13 static ZCONST char Far DiskFullQuery[] =
14 @@ -2300,7 +2302,13 @@ int do_string(__G__ length, option) /* return PK-type error code */
15 length = length2;
16 }
17 /* Looks like here is where extra fields are read */
18 - getZip64Data(__G__ G.extra_field, length);
19 + if (getZip64Data(__G__ G.extra_field, length) != PK_COOL)
20 + {
21 + Info(slide, 0x401, ((char *)slide,
22 + LoadFarString( ExtraFieldCorrupt), EF_PKSZ64));
23 + error = PK_WARN;
24 + }
25 +
26 #ifdef UNICODE_SUPPORT
27 G.unipath_filename = NULL;
28 if (G.UzO.U_flag < 2) {
29 diff --git a/process.c b/process.c
30 index be6e006..0d57ab4 100644
31 --- a/process.c
32 +++ b/process.c
33 @@ -1,5 +1,5 @@
34 /*
35 - Copyright (c) 1990-2009 Info-ZIP. All rights reserved.
36 + Copyright (c) 1990-2014 Info-ZIP. All rights reserved.
37
38 See the accompanying file LICENSE, version 2009-Jan-02 or later
39 (the contents of which are also included in unzip.h) for terms of use.
40 @@ -1894,48 +1894,83 @@ int getZip64Data(__G__ ef_buf, ef_len)
41 and a 4-byte version of disk start number.
42 Sets both local header and central header fields. Not terribly clever,
43 but it means that this procedure is only called in one place.
44 +
45 + 2014-12-05 SMS.
46 + Added checks to ensure that enough data are available before calling
47 + makeint64() or makelong(). Replaced various sizeof() values with
48 + simple ("4" or "8") constants. (The Zip64 structures do not depend
49 + on our variable sizes.) Error handling is crude, but we should now
50 + stay within the buffer.
51 ---------------------------------------------------------------------------*/
52
53 +#define Z64FLGS 0xffff
54 +#define Z64FLGL 0xffffffff
55 +
56 if (ef_len == 0 || ef_buf == NULL)
57 return PK_COOL;
58
59 Trace((stderr,"\ngetZip64Data: scanning extra field of length %u\n",
60 ef_len));
61
62 - while (ef_len >= EB_HEADSIZE) {
63 + while (ef_len >= EB_HEADSIZE)
64 + {
65 eb_id = makeword(EB_ID + ef_buf);
66 eb_len = makeword(EB_LEN + ef_buf);
67
68 - if (eb_len > (ef_len - EB_HEADSIZE)) {
69 - /* discovered some extra field inconsistency! */
70 + if (eb_len > (ef_len - EB_HEADSIZE))
71 + {
72 + /* Extra block length exceeds remaining extra field length. */
73 Trace((stderr,
74 "getZip64Data: block length %u > rest ef_size %u\n", eb_len,
75 ef_len - EB_HEADSIZE));
76 break;
77 }
78 - if (eb_id == EF_PKSZ64) {
79
80 + if (eb_id == EF_PKSZ64)
81 + {
82 int offset = EB_HEADSIZE;
83
84 - if (G.crec.ucsize == 0xffffffff || G.lrec.ucsize == 0xffffffff){
85 - G.lrec.ucsize = G.crec.ucsize = makeint64(offset + ef_buf);
86 - offset += sizeof(G.crec.ucsize);
87 + if ((G.crec.ucsize == Z64FLGL) || (G.lrec.ucsize == Z64FLGL))
88 + {
89 + if (offset+ 8 > ef_len)
90 + return PK_ERR;
91 +
92 + G.crec.ucsize = G.lrec.ucsize = makeint64(offset + ef_buf);
93 + offset += 8;
94 }
95 - if (G.crec.csize == 0xffffffff || G.lrec.csize == 0xffffffff){
96 - G.csize = G.lrec.csize = G.crec.csize = makeint64(offset + ef_buf);
97 - offset += sizeof(G.crec.csize);
98 +
99 + if ((G.crec.csize == Z64FLGL) || (G.lrec.csize == Z64FLGL))
100 + {
101 + if (offset+ 8 > ef_len)
102 + return PK_ERR;
103 +
104 + G.csize = G.crec.csize = G.lrec.csize = makeint64(offset + ef_buf);
105 + offset += 8;
106 }
107 - if (G.crec.relative_offset_local_header == 0xffffffff){
108 +
109 + if (G.crec.relative_offset_local_header == Z64FLGL)
110 + {
111 + if (offset+ 8 > ef_len)
112 + return PK_ERR;
113 +
114 G.crec.relative_offset_local_header = makeint64(offset + ef_buf);
115 - offset += sizeof(G.crec.relative_offset_local_header);
116 + offset += 8;
117 }
118 - if (G.crec.disk_number_start == 0xffff){
119 +
120 + if (G.crec.disk_number_start == Z64FLGS)
121 + {
122 + if (offset+ 4 > ef_len)
123 + return PK_ERR;
124 +
125 G.crec.disk_number_start = (zuvl_t)makelong(offset + ef_buf);
126 - offset += sizeof(G.crec.disk_number_start);
127 + offset += 4;
128 }
129 +#if 0
130 + break; /* Expect only one EF_PKSZ64 block. */
131 +#endif /* 0 */
132 }
133
134 - /* Skip this extra field block */
135 + /* Skip this extra field block. */
136 ef_buf += (eb_len + EB_HEADSIZE);
137 ef_len -= (eb_len + EB_HEADSIZE);
138 }