Blame SOURCES/CVE-2018-7159-Fix-Content-Lenght-with-obsolete-line-folding-backport.patch

89295e
diff -up http-parser-2.7.1/http_parser.c.cve http-parser-2.7.1/http_parser.c
89295e
--- http-parser-2.7.1/http_parser.c.cve	2019-03-23 09:08:12.831806096 +0100
89295e
+++ http-parser-2.7.1/http_parser.c	2019-03-23 09:09:45.047875248 +0100
89295e
@@ -1483,6 +1483,11 @@ reexecute:
89295e
             parser->header_state = h_content_length_num;
89295e
             break;
89295e
 
89295e
+          /* when obsolete line folding is encountered for content length
89295e
+           * continue to the s_header_value state */
89295e
+          case h_content_length_ws:
89295e
+            break;
89295e
+
89295e
           case h_connection:
89295e
             /* looking for 'Connection: keep-alive' */
89295e
             if (c == 'k') {
89295e
@@ -1727,6 +1732,10 @@ reexecute:
89295e
       case s_header_value_lws:
89295e
       {
89295e
         if (ch == ' ' || ch == '\t') {
89295e
+          if (parser->header_state == h_content_length_num) {
89295e
+              /* treat obsolete line folding as space */
89295e
+              parser->header_state = h_content_length_ws;
89295e
+          }
89295e
           UPDATE_STATE(s_header_value_start);
89295e
           REEXECUTE();
89295e
         }
89295e
diff -up http-parser-2.7.1/test.c.cve http-parser-2.7.1/test.c
89295e
--- http-parser-2.7.1/test.c.cve	2019-03-23 09:08:12.831806096 +0100
89295e
+++ http-parser-2.7.1/test.c	2019-03-23 09:09:45.049875249 +0100
89295e
@@ -3968,6 +3968,20 @@ main (void)
89295e
       HPE_INVALID_CONTENT_LENGTH,
89295e
       HTTP_REQUEST);
89295e
 
89295e
+  test_simple_type(
89295e
+      "POST / HTTP/1.1\r\n"
89295e
+      "Content-Length:  42\r\n"
89295e
+      " Hello world!\r\n",
89295e
+      HPE_INVALID_CONTENT_LENGTH,
89295e
+      HTTP_REQUEST);
89295e
+
89295e
+  test_simple_type(
89295e
+      "POST / HTTP/1.1\r\n"
89295e
+      "Content-Length:  42\r\n"
89295e
+      " \r\n",
89295e
+      HPE_OK,
89295e
+      HTTP_REQUEST);
89295e
+
89295e
   //// RESPONSES
89295e
 
89295e
   for (i = 0; i < response_count; i++) {