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