Browse code

curl : Fix CVE-2017-1000254

Change-Id: I10e4161674b45d32037d5dfdf7cf28d90be948af
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/4266
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>

xiaolin-vmware authored on 2017/11/07 04:08:35
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,133 @@
0
+From 9d9157bb0c230c769fdf902ed3a62edf642d424b Mon Sep 17 00:00:00 2001
1
+From: Daniel Stenberg <daniel@haxx.se>
2
+Date: Mon, 25 Sep 2017 00:35:22 +0200
3
+Subject: [PATCH v2] FTP: zero terminate the entry path even on bad input
4
+
5
+... a single double quote could leave the entry path buffer without a zero
6
+terminating byte.
7
+
8
+Test 1152 added to verify.
9
+
10
+Reported-by: Max Dymond
11
+---
12
+ lib/ftp.c               |  7 ++++--
13
+ tests/data/Makefile.inc |  1 +
14
+ tests/data/test1152     | 61 +++++++++++++++++++++++++++++++++++++++++++++++++
15
+ 3 files changed, 67 insertions(+), 2 deletions(-)
16
+ create mode 100644 tests/data/test1152
17
+
18
+diff --git a/lib/ftp.c b/lib/ftp.c
19
+index 4860509f3..54ba4057f 100644
20
+--- a/lib/ftp.c
21
+@@ -2826,7 +2826,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
22
+         const size_t buf_size = data->set.buffer_size;
23
+         char *dir;
24
+         char *store;
25
+-
26
++        bool entry_extracted = FALSE;
27
+         dir = malloc(nread + 1);
28
+         if(!dir)
29
+           return CURLE_OUT_OF_MEMORY;
30
+@@ -2857,7 +2857,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
31
+               }
32
+               else {
33
+                 /* end of path */
34
+-                *store = '\0'; /* zero terminate */
35
++                entry_extracted = TRUE;
36
+                 break; /* get out of this loop */
37
+               }
38
+             }
39
+@@ -2866,7 +2866,9 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
40
+             store++;
41
+             ptr++;
42
+           }
43
+-
44
++          *store = '\0'; /* zero terminate */
45
++        }
46
++        if(entry_extracted) {
47
+           /* If the path name does not look like an absolute path (i.e.: it
48
+              does not start with a '/'), we probably need some server-dependent
49
+              adjustments. For example, this is the case when connecting to
50
+diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc
51
+index 1bfd75eca..268f5e29e 100644
52
+--- a/tests/data/Makefile.inc
53
+@@ -121,6 +121,7 @@ test1120 test1121 test1122 test1123 test1124 test1125 test1126 test1127 \
54
+ test1128 test1129 test1130 test1131 test1132 test1133 test1134 test1135 \
55
+ test1136 test1137 test1138 test1139 test1140 test1141 test1142 test1143 \
56
+ test1144 test1145 test1146 \
57
++test1152 \
58
+ test1200 test1201 test1202 test1203 test1204 test1205 test1206 test1207 \
59
+ test1208 test1209 test1210 test1211 test1212 test1213 test1214 test1215 \
60
+ test1216 test1217 test1218 test1219 \
61
+diff --git a/tests/data/test1152 b/tests/data/test1152
62
+new file mode 100644
63
+index 000000000..aa8c0a7e4
64
+--- /dev/null
65
+@@ -0,0 +1,61 @@
66
++<testcase>
67
++<info>
68
++<keywords>
69
++FTP
70
++PASV
71
++LIST
72
++</keywords>
73
++</info>
74
++#
75
++# Server-side
76
++<reply>
77
++<servercmd>
78
++REPLY PWD 257 "just one
79
++</servercmd>
80
++
81
++# When doing LIST, we get the default list output hard-coded in the test
82
++# FTP server
83
++<data mode="text">
84
++total 20
85
++drwxr-xr-x   8 98       98           512 Oct 22 13:06 .
86
++drwxr-xr-x   8 98       98           512 Oct 22 13:06 ..
87
++drwxr-xr-x   2 98       98           512 May  2  1996 curl-releases
88
++-r--r--r--   1 0        1             35 Jul 16  1996 README
89
++lrwxrwxrwx   1 0        1              7 Dec  9  1999 bin -> usr/bin
90
++dr-xr-xr-x   2 0        1            512 Oct  1  1997 dev
91
++drwxrwxrwx   2 98       98           512 May 29 16:04 download.html
92
++dr-xr-xr-x   2 0        1            512 Nov 30  1995 etc
93
++drwxrwxrwx   2 98       1            512 Oct 30 14:33 pub
94
++dr-xr-xr-x   5 0        1            512 Oct  1  1997 usr
95
++</data>
96
++</reply>
97
++
98
++#
99
++# Client-side
100
++<client>
101
++<server>
102
++ftp
103
++</server>
104
++ <name>
105
++FTP with uneven quote in PWD response
106
++ </name>
107
++ <command>
108
++ftp://%HOSTIP:%FTPPORT/test-1152/
109
++</command>
110
++</client>
111
++
112
++#
113
++# Verify data after the test has been "shot"
114
++<verify>
115
++<protocol>
116
++USER anonymous
117
++PASS ftp@example.com
118
++PWD
119
++CWD test-1152
120
++EPSV
121
++TYPE A
122
++LIST
123
++QUIT
124
++</protocol>
125
++</verify>
126
++</testcase>
127
+-- 
128
+2.14.1
129
+
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:        An URL retrieval utility and library
2 2
 Name:           curl
3 3
 Version:        7.54.1
4
-Release:        2%{?dist}
4
+Release:        3%{?dist}
5 5
 License:        MIT
6 6
 URL:            http://curl.haxx.se
7 7
 Group:          System Environment/NetworkingLibraries
... ...
@@ -12,6 +12,7 @@ Source0:        http://curl.haxx.se/download/%{name}-%{version}.tar.lzma
12 12
 Patch0:         curl-CVE-2017-1000099.patch
13 13
 Patch1:         curl-CVE-2017-1000100.patch
14 14
 Patch2:         curl-CVE-2017-1000101.patch
15
+Patch3:         curl-CVE-2017-1000254.patch
15 16
 BuildRequires:  ca-certificates
16 17
 BuildRequires:  openssl-devel
17 18
 BuildRequires:  krb5-devel
... ...
@@ -47,6 +48,7 @@ This package contains minimal set of shared curl libraries.
47 47
 %patch0 -p1
48 48
 %patch1 -p1
49 49
 %patch2 -p1
50
+%patch3 -p1
50 51
 %build
51 52
 ./configure \
52 53
     CFLAGS="%{optflags}" \
... ...
@@ -94,6 +96,8 @@ rm -rf %{buildroot}/*
94 94
 %{_libdir}/libcurl.so.*
95 95
 
96 96
 %changelog
97
+*   Mon Nov 06 2017 Xiaolin Li <xiaolinl@vmware.com> 7.54.1-3
98
+-   Fix CVE-2017-1000254
97 99
 *   Thu Nov 02 2017 Xiaolin Li <xiaolinl@vmware.com> 7.54.1-2
98 100
 -   Fix CVE-2017-1000099, CVE-2017-1000100, CVE-2017-1000101
99 101
 *   Tue Jul 11 2017 Divya Thaluru <dthaluru@vmware.com> 7.54.1-1