gnu: glib: Fix CVE-2021-27218 and CVE-2021-27219.
[jackhill/guix/guix.git] / gnu / packages / patches / unzip-overflow-long-fsize.patch
CommitLineData
48e4a9f3
MW
1Copied from Fedora.
2
3http://pkgs.fedoraproject.org/cgit/unzip.git/plain/unzip-6.0-overflow-long-fsize.patch?id=d18f821e
4
5diff --git a/list.c b/list.c
6index f7359c3..4c3d703 100644
7--- a/list.c
8+++ b/list.c
9@@ -97,7 +97,7 @@ int list_files(__G) /* return PK-type error code */
10 {
11 int do_this_file=FALSE, cfactor, error, error_in_archive=PK_COOL;
12 #ifndef WINDLL
13- char sgn, cfactorstr[10];
14+ char sgn, cfactorstr[13];
15 int longhdr=(uO.vflag>1);
16 #endif
17 int date_format;
18@@ -339,7 +339,19 @@ int list_files(__G) /* return PK-type error code */
19 G.crec.compression_method == ENHDEFLATED) {
20 methbuf[5] = dtype[(G.crec.general_purpose_bit_flag>>1) & 3];
21 } else if (methnum >= NUM_METHODS) {
22- sprintf(&methbuf[4], "%03u", G.crec.compression_method);
23+ /* 2013-02-26 SMS.
24+ * http://sourceforge.net/tracker/?func=detail
25+ * &aid=2861648&group_id=118012&atid=679786
26+ * Unexpectedly large compression methods overflow
27+ * &methbuf[]. Use the old, three-digit decimal format
28+ * for values which fit. Otherwise, sacrifice the
29+ * colon, and use four-digit hexadecimal.
30+ */
31+ if (G.crec.compression_method <= 999) {
32+ sprintf( &methbuf[ 4], "%03u", G.crec.compression_method);
33+ } else {
34+ sprintf( &methbuf[ 3], "%04X", G.crec.compression_method);
35+ }
36 }
37
38 #if 0 /* GRR/Euro: add this? */