]> granicus.if.org Git - curl/commitdiff
glob: do not continue parsing after a strtoul() overflow range
authorDaniel Stenberg <daniel@haxx.se>
Tue, 1 Aug 2017 15:16:07 +0000 (17:16 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 7 Aug 2017 07:24:30 +0000 (09:24 +0200)
Added test 1289 to verify.

CVE-2017-1000101

Bug: https://curl.haxx.se/docs/adv_20170809A.html
Reported-by: Brian Carpenter
src/tool_urlglob.c
tests/data/Makefile.inc
tests/data/test1289 [new file with mode: 0644]

index 6b1ece008b35da069210b02c99f14d6bf336d83c..d56dcd912f07ad64273cfba9df08535dd6432fef 100644 (file)
@@ -273,7 +273,10 @@ static CURLcode glob_range(URLGlob *glob, char **patternp,
         }
         errno = 0;
         max_n = strtoul(pattern, &endp, 10);
-        if(errno || (*endp == ':')) {
+        if(errno)
+          /* overflow */
+          endp = NULL;
+        else if(*endp == ':') {
           pattern = endp+1;
           errno = 0;
           step_n = strtoul(pattern, &endp, 10);
index 35446cf71b36b1e55193246ac907870066e086f7..59f692e8f40f10be73e17b8de88904f2b75d848a 100644 (file)
@@ -132,7 +132,7 @@ test1252 test1253 test1254 test1255 test1256 test1257 test1258 test1259 \
 test1260 test1261 test1262 \
 \
 test1280 test1281 test1282 test1283 test1284 test1285 test1286 test1287 \
-test1288 \
+test1288 test1289 \
 test1298 test1299 \
 test1300 test1301 test1302 test1303 test1304 test1305 test1306 test1307 \
 test1308 test1309 test1310 test1311 test1312 test1313 test1314 test1315 \
diff --git a/tests/data/test1289 b/tests/data/test1289
new file mode 100644 (file)
index 0000000..d679cc0
--- /dev/null
@@ -0,0 +1,35 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+globbing
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+<name>
+globbing with overflow and bad syntxx
+</name>
+<command>
+http://ur%20[0-60000000000000000000
+</command>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+# curl: (3) [globbing] bad range in column 
+<errorcode>
+3
+</errorcode>
+</verify>
+</testcase>