d0ba002
From 8846a6507283f2bfe439cc3679ac81aca5ee3447 Mon Sep 17 00:00:00 2001
d0ba002
From: Daniel Stenberg <daniel@haxx.se>
d0ba002
Date: Tue, 1 Aug 2017 17:16:07 +0200
d0ba002
Subject: [PATCH] glob: do not continue parsing after a strtoul() overflow
d0ba002
 range
d0ba002
d0ba002
Added test 1289 to verify.
d0ba002
d0ba002
CVE-2017-1000101
d0ba002
d0ba002
Bug: https://curl.haxx.se/docs/adv_20170809A.html
d0ba002
Reported-by: Brian Carpenter
d0ba002
d0ba002
Upstream-commit: 453e7a7a03a2cec749abd3878a48e728c515cca7
d0ba002
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
d0ba002
---
d0ba002
 src/tool_urlglob.c      |  5 ++++-
d0ba002
 tests/data/Makefile.inc |  2 +-
d0ba002
 tests/data/test1289     | 35 +++++++++++++++++++++++++++++++++++
d0ba002
 3 files changed, 40 insertions(+), 2 deletions(-)
d0ba002
 create mode 100644 tests/data/test1289
d0ba002
d0ba002
diff --git a/src/tool_urlglob.c b/src/tool_urlglob.c
d0ba002
index d002f27..caf2385 100644
d0ba002
--- a/src/tool_urlglob.c
d0ba002
+++ b/src/tool_urlglob.c
d0ba002
@@ -269,7 +269,10 @@ static CURLcode glob_range(URLGlob *glob, char **patternp,
d0ba002
         }
d0ba002
         errno = 0;
d0ba002
         max_n = strtoul(pattern, &endp, 10);
d0ba002
-        if(errno || (*endp == ':')) {
d0ba002
+        if(errno)
d0ba002
+          /* overflow */
d0ba002
+          endp = NULL;
d0ba002
+        else if(*endp == ':') {
d0ba002
           pattern = endp+1;
d0ba002
           errno = 0;
d0ba002
           step_n = strtoul(pattern, &endp, 10);
d0ba002
diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc
d0ba002
index ecfedc9..be69e7c 100644
d0ba002
--- a/tests/data/Makefile.inc
d0ba002
+++ b/tests/data/Makefile.inc
d0ba002
@@ -128,7 +128,7 @@ test1220 test1221 test1222 test1223 test1224 test1225 test1226 test1227 \
d0ba002
 test1228 test1229 test1230 test1231 test1232 test1233 test1234 test1235 \
d0ba002
 test1236 test1237 test1238 test1239 test1240 test1241 test1242 test1243 \
d0ba002
 test1244 test1245 test1246 \
d0ba002
-\
d0ba002
+test1289 \
d0ba002
 test1300 test1301 test1302 test1303 test1304 test1305 test1306 test1307 \
d0ba002
 test1308 test1309 test1310 test1311 test1312 test1313 test1314 test1315 \
d0ba002
 test1316 test1317 test1318 test1319 test1320 test1321 test1322          \
d0ba002
diff --git a/tests/data/test1289 b/tests/data/test1289
d0ba002
new file mode 100644
d0ba002
index 0000000..d679cc0
d0ba002
--- /dev/null
d0ba002
+++ b/tests/data/test1289
d0ba002
@@ -0,0 +1,35 @@
d0ba002
+<testcase>
d0ba002
+<info>
d0ba002
+<keywords>
d0ba002
+HTTP
d0ba002
+HTTP GET
d0ba002
+globbing
d0ba002
+</keywords>
d0ba002
+</info>
d0ba002
+
d0ba002
+#
d0ba002
+# Server-side
d0ba002
+<reply>
d0ba002
+</reply>
d0ba002
+
d0ba002
+# Client-side
d0ba002
+<client>
d0ba002
+<server>
d0ba002
+http
d0ba002
+</server>
d0ba002
+<name>
d0ba002
+globbing with overflow and bad syntxx
d0ba002
+</name>
d0ba002
+<command>
d0ba002
+http://ur%20[0-60000000000000000000
d0ba002
+</command>
d0ba002
+</client>
d0ba002
+
d0ba002
+# Verify data after the test has been "shot"
d0ba002
+<verify>
d0ba002
+# curl: (3) [globbing] bad range in column 
d0ba002
+<errorcode>
d0ba002
+3
d0ba002
+</errorcode>
d0ba002
+</verify>
d0ba002
+</testcase>
d0ba002
-- 
d0ba002
2.9.4
d0ba002