* added graalvm (22.0.0.1) - A high-performance JDK distribution
[t2.git] / package / archiver / unzip / CVE-2016-9844.patch
blob735f7dc47456e9f284be8ff3141ebcfd2235fe1c
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/unzip/CVE-2016-9844.patch
3 # Copyright (C) 2021 The T2 SDE Project
4 #
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
7 #
8 # This patch file is dual-licensed. It is available under the license the
9 # patched project is licensed under, as long as it is an OpenSource license
10 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
11 # of the GNU General Public License version 2 as used by the T2 SDE.
12 # --- T2-COPYRIGHT-NOTE-END ---
14 From: "Steven M. Schweda" <sms@antinode.info>
15 Subject: Fix CVE-2016-9844, buffer overflow in zipinfo
16 Bug-Debian: https://bugs.debian.org/847486
17 Bug-Ubuntu: https://launchpad.net/bugs/1643750
18 X-Debian-version: 6.0-21
20 --- a/zipinfo.c
21 +++ b/zipinfo.c
22 @@ -1921,7 +1921,18 @@
23 ush dnum=(ush)((G.crec.general_purpose_bit_flag>>1) & 3);
24 methbuf[3] = dtype[dnum];
25 } else if (methnum >= NUM_METHODS) { /* unknown */
26 - sprintf(&methbuf[1], "%03u", G.crec.compression_method);
27 + /* 2016-12-05 SMS.
28 + * https://launchpad.net/bugs/1643750
29 + * Unexpectedly large compression methods overflow
30 + * &methbuf[]. Use the old, three-digit decimal format
31 + * for values which fit. Otherwise, sacrifice the "u",
32 + * and use four-digit hexadecimal.
33 + */
34 + if (G.crec.compression_method <= 999) {
35 + sprintf( &methbuf[ 1], "%03u", G.crec.compression_method);
36 + } else {
37 + sprintf( &methbuf[ 0], "%04X", G.crec.compression_method);
38 + }
41 for (k = 0; k < 15; ++k)