blob: 4d758572ac49078209f349f1ec5d5153f1153595 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From: "Steven M. Schweda" <sms@antinode.info>
2Subject: Fix CVE-2016-9844, buffer overflow in zipinfo
3Bug-Debian: https://bugs.debian.org/847486
4Bug-Ubuntu: https://launchpad.net/bugs/1643750
5X-Debian-version: 6.0-21
6
7--- a/zipinfo.c
8+++ b/zipinfo.c
9@@ -1921,7 +1921,18 @@ static int zi_short(__G) /* return PK-
10 ush dnum=(ush)((G.crec.general_purpose_bit_flag>>1) & 3);
11 methbuf[3] = dtype[dnum];
12 } else if (methnum >= NUM_METHODS) { /* unknown */
13- sprintf(&methbuf[1], "%03u", G.crec.compression_method);
14+ /* 2016-12-05 SMS.
15+ * https://launchpad.net/bugs/1643750
16+ * Unexpectedly large compression methods overflow
17+ * &methbuf[]. Use the old, three-digit decimal format
18+ * for values which fit. Otherwise, sacrifice the "u",
19+ * and use four-digit hexadecimal.
20+ */
21+ if (G.crec.compression_method <= 999) {
22+ sprintf( &methbuf[ 1], "%03u", G.crec.compression_method);
23+ } else {
24+ sprintf( &methbuf[ 0], "%04X", G.crec.compression_method);
25+ }
26 }
27
28 for (k = 0; k < 15; ++k)