Blame SOURCES/CVE-2018-7159-Dissallow-empty-Content-Length.patch

89295e
From 350258965909f249f9c59823aac240313e0d0120 Mon Sep 17 00:00:00 2001
89295e
From: Olga Batyshkina <olga.batyshkina@virtual-solution.com>
89295e
Date: Wed, 19 Dec 2018 16:02:23 +0100
89295e
Subject: [PATCH] Disallow empty Content-Length
89295e
89295e
PR-URL: https://github.com/nodejs/http-parser/pull/459
89295e
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
89295e
---
89295e
 http_parser.c | 5 +++++
89295e
 test.c        | 7 +++++++
89295e
 2 files changed, 12 insertions(+)
89295e
89295e
diff --git a/http_parser.c b/http_parser.c
89295e
index cd5d0d5..228ada5 100644
89295e
--- a/http_parser.c
89295e
+++ b/http_parser.c
89295e
@@ -1740,6 +1740,11 @@ size_t http_parser_execute (http_parser *parser,
89295e
             case h_transfer_encoding_chunked:
89295e
               parser->flags |= F_CHUNKED;
89295e
               break;
89295e
+            case h_content_length:
89295e
+              /* do not allow empty content length */
89295e
+              SET_ERRNO(HPE_INVALID_CONTENT_LENGTH);
89295e
+              goto error;
89295e
+              break;
89295e
             default:
89295e
               break;
89295e
           }
89295e
diff --git a/test.c b/test.c
89295e
index 25c8f5f..c3fddd5 100644
89295e
--- a/test.c
89295e
+++ b/test.c
89295e
@@ -4182,6 +4182,13 @@ main (void)
89295e
   test_invalid_header_field_token_error(HTTP_RESPONSE);
89295e
   test_invalid_header_field_content_error(HTTP_RESPONSE);
89295e
 
89295e
+  test_simple_type(
89295e
+      "POST / HTTP/1.1\r\n"
89295e
+      "Content-Length:\r\n"  // empty
89295e
+      "\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"  // Note the surrounding whitespace.