Browse code

unzip: Fix for CVE-2018-18384

Added a patch to fix the CVE-2018-18384

Change-Id: I84ab2763c9d76d6e4072e564a236ee8f52152d37
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/6583
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Ajay Kaher <akaher@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>

Ankit Jain authored on 2019/01/25 02:40:48
Showing 2 changed files
... ...
@@ -4,7 +4,7 @@
4 4
 Summary:        Unzip-6.0
5 5
 Name:           unzip
6 6
 Version:        6.0
7
-Release:        9%{?dist}
7
+Release:        10%{?dist}
8 8
 License:        BSD
9 9
 URL:            http://www.gnu.org/software/%{name}
10 10
 Source0:        http://downloads.sourceforge.net/infozip/unzip60.tar.gz
... ...
@@ -19,10 +19,11 @@ Patch2:         CVE-2015-7696-CVE-2015-7697.patch
19 19
 Patch3:         unzip-CVE-2014-9844.patch
20 20
 Patch4:         unzip-CVE-2014-9913.patch
21 21
 Patch5:         unzip-CVE-2018-1000035.patch
22
+Patch6:         unzip_cfactor_overflow.patch
22 23
 
23 24
 %description
24
-The UnZip package contains ZIP extraction utilities. These are useful 
25
-for extracting files from ZIP archives. ZIP archives are created 
25
+The UnZip package contains ZIP extraction utilities. These are useful
26
+for extracting files from ZIP archives. ZIP archives are created
26 27
 with PKZIP or Info-ZIP utilities, primarily in a DOS environment.
27 28
 
28 29
 %prep
... ...
@@ -33,6 +34,7 @@ with PKZIP or Info-ZIP utilities, primarily in a DOS environment.
33 33
 %patch3 -p1
34 34
 %patch4 -p1
35 35
 %patch5 -p1
36
+%patch6 -p1
36 37
 
37 38
 %build
38 39
 case `uname -m` in
... ...
@@ -63,6 +65,8 @@ make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck}
63 63
 %{_bindir}/*
64 64
 
65 65
 %changelog
66
+*   Thu Jan 24 2019 Ankit Jain <ankitja@vmware.com> 6.0-10
67
+-   Fix for CVE-2018-18384
66 68
 *   Tue May 29 2018 Xiaolin Li <xiaolinl@vmware.com> 6.0-9
67 69
 -   Fix CVE-2018-1000035
68 70
 *   Fri Oct 20 2017 Xiaolin Li <xiaolinl@vmware.com> 6.0-8
69 71
new file mode 100644
... ...
@@ -0,0 +1,45 @@
0
+There was a buffer overflow detected in list.c file where cfactorstr[] had an insufficient size (10). It was fixed in unzip beta versions and expanded to size 12 but I think it's still insufficient. The right size should be 13 (sgn (1), int (10), % (1), nul (1)).
1
+
2
+Also, replacing sprintf() by snprintf() might make the code more robust.
3
+Kudos to Josef Möllers (josef.moellers@suse.com).
4
+
5
+Refs: https://sourceforge.net/p/infozip/bugs/53/
6
+      CVE-2018-18384
7
+
8
+diff --git a/list.c b/list.c
9
+index 15e0011..a770ae7 100644
10
+--- a/list.c
11
+@@ -97,7 +97,7 @@ int list_files(__G)    /* return PK-type error code */
12
+ {
13
+     int do_this_file=FALSE, cfactor, error, error_in_archive=PK_COOL;
14
+ #ifndef WINDLL
15
+-    char sgn, cfactorstr[10];
16
++    char sgn, cfactorstr[1+10+1+1];	/* <sgn><int>%NUL */
17
+     int longhdr=(uO.vflag>1);
18
+ #endif
19
+     int date_format;
20
+@@ -378,9 +378,9 @@ int list_files(__G)    /* return PK-type error code */
21
+             }
22
+ #else /* !WINDLL */
23
+             if (cfactor == 100)
24
+-                sprintf(cfactorstr, LoadFarString(CompFactor100));
25
++                snprintf(cfactorstr, sizeof(cfactorstr), LoadFarString(CompFactor100));
26
+             else
27
+-                sprintf(cfactorstr, LoadFarString(CompFactorStr), sgn, cfactor);
28
++                snprintf(cfactorstr, sizeof(cfactorstr), LoadFarString(CompFactorStr), sgn, cfactor);
29
+             if (longhdr)
30
+                 Info(slide, 0, ((char *)slide, LoadFarString(LongHdrStats),
31
+                   FmZofft(G.crec.ucsize, "8", "u"), methbuf,
32
+@@ -460,9 +460,9 @@ int list_files(__G)    /* return PK-type error code */
33
+ 
34
+ #else /* !WINDLL */
35
+         if (cfactor == 100)
36
+-            sprintf(cfactorstr, LoadFarString(CompFactor100));
37
++            snprintf(cfactorstr, sizeof(cfactorstr), LoadFarString(CompFactor100));
38
+         else
39
+-            sprintf(cfactorstr, LoadFarString(CompFactorStr), sgn, cfactor);
40
++            snprintf(cfactorstr, sizeof(cfactorstr), LoadFarString(CompFactorStr), sgn, cfactor);
41
+         if (longhdr) {
42
+             Info(slide, 0, ((char *)slide, LoadFarString(LongFileTrailer),
43
+               FmZofft(tot_ucsize, "8", "u"), FmZofft(tot_csize, "8", "u"),