]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http: reject HTTP response codes < 100
authorDaniel Stenberg <daniel@haxx.se>
Tue, 26 Oct 2021 15:47:14 +0000 (17:47 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 27 Oct 2021 08:26:15 +0000 (10:26 +0200)
... which then also includes negative ones as test 1430 uses.

This makes native + hyper backend act identically on this and therefore
test 1430 can now be enabled when building with hyper. Adjust test 1431
as well.

Closes #7909

lib/http.c
tests/data/DISABLED
tests/data/test1430
tests/data/test1431

index 4777750ec297283147b96c6f3044ac3e1f4caf36..78ad10edeadd5874e4a112125648f5abc9cb52a8 100644 (file)
@@ -4240,8 +4240,12 @@ CURLcode Curl_http_readwrite_headers(struct Curl_easy *data,
 
         /* There can only be a 4th response code digit stored in 'digit4' if
            all the other fields were parsed and stored first, so nc is 5 when
-           digit4 a digit */
-        else if(ISDIGIT(digit4)) {
+           digit4 a digit.
+
+           The sscanf() line above will also allow zero-prefixed and negative
+           numbers, so we check for that too here.
+        */
+        else if(ISDIGIT(digit4) || (k->httpcode < 100)) {
           failf(data, "Unsupported response code in HTTP response");
           return CURLE_UNSUPPORTED_PROTOCOL;
         }
index c6998993d2f5b6763ee507e201572d1e52290f70..792bfb090e5a4f4897bb559c3ee86a6b3ae20445 100644 (file)
@@ -65,8 +65,6 @@
 1156
 1160
 1417
-1430
-1431
 1455
 1456
 1525
index 3dbeae8560ec7f346bb47050270cd8c9fc5ff8c3..8ed513c6069e0b63a8a4d93f83a04481b1c3004c 100644 (file)
@@ -7,7 +7,7 @@ HTTP GET
 </info>
 
 <reply>
-<data>
+<data nocheck="yes">
 HTTP/1.1 -12 OK
 Date: Tue, 09 Nov 2010 14:49:00 GMT
 Server: test-server/fake
@@ -47,5 +47,10 @@ User-Agent: curl/%VERSION
 Accept: */*\r
 \r
 </protocol>
+# 1 - CURLE_UNSUPPORTED_PROTOCOL
+# Due to invalid HTTP response code
+<errorcode>
+1
+</errorcode>
 </verify>
 </testcase>
index be6277d89b2c8d9345473f486a71c7334cfb6d4b..26cf4aaf794db91d09447d0a3350be3dde4a35b1 100644 (file)
@@ -7,7 +7,7 @@ HTTP GET
 </info>
 
 <reply>
-<data>
+<data nocheck="yes">
 HTTP/1.1 2 OK
 Date: Tue, 09 Nov 2010 14:49:00 GMT
 Server: test-server/fake
@@ -47,5 +47,8 @@ User-Agent: curl/%VERSION
 Accept: */*\r
 \r
 </protocol>
+<errorcode>
+1
+</errorcode>
 </verify>
 </testcase>