Commit ce962c3f authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Merge branch 'update-http-parser'

parents d978f351 f931504e
...@@ -1496,28 +1496,24 @@ reexecute: ...@@ -1496,28 +1496,24 @@ reexecute:
switch (h_state) { switch (h_state) {
case h_general: case h_general:
{ {
const char* p_cr; const char* limit = p + MIN(data + len - p, max_header_size);
const char* p_lf;
size_t limit = data + len - p; for (; p != limit; p++) {
ch = *p;
limit = MIN(limit, max_header_size); if (ch == CR || ch == LF) {
--p;
p_cr = (const char*) memchr(p, CR, limit); break;
p_lf = (const char*) memchr(p, LF, limit); }
if (p_cr != NULL) { if (!lenient && !IS_HEADER_CHAR(ch)) {
if (p_lf != NULL && p_cr >= p_lf) SET_ERRNO(HPE_INVALID_HEADER_TOKEN);
p = p_lf; goto error;
else }
p = p_cr; }
} else if (UNLIKELY(p_lf != NULL)) { if (p == data + len)
p = p_lf; --p;
} else { break;
p = data + len;
} }
--p;
break;
}
case h_connection: case h_connection:
case h_transfer_encoding: case h_transfer_encoding:
......
...@@ -27,7 +27,7 @@ extern "C" { ...@@ -27,7 +27,7 @@ extern "C" {
/* Also update SONAME in the Makefile whenever you change these. */ /* Also update SONAME in the Makefile whenever you change these. */
#define HTTP_PARSER_VERSION_MAJOR 2 #define HTTP_PARSER_VERSION_MAJOR 2
#define HTTP_PARSER_VERSION_MINOR 9 #define HTTP_PARSER_VERSION_MINOR 9
#define HTTP_PARSER_VERSION_PATCH 0 #define HTTP_PARSER_VERSION_PATCH 1
#include <stddef.h> #include <stddef.h>
#if defined(_WIN32) && !defined(__MINGW32__) && \ #if defined(_WIN32) && !defined(__MINGW32__) && \
......
...@@ -4316,6 +4316,9 @@ main (void) ...@@ -4316,6 +4316,9 @@ main (void)
test_simple("GET / HTTP/11.1\r\n\r\n", HPE_INVALID_VERSION); test_simple("GET / HTTP/11.1\r\n\r\n", HPE_INVALID_VERSION);
test_simple("GET / HTTP/1.01\r\n\r\n", HPE_INVALID_VERSION); test_simple("GET / HTTP/1.01\r\n\r\n", HPE_INVALID_VERSION);
test_simple("GET / HTTP/1.0\r\nHello: w\1rld\r\n\r\n", HPE_INVALID_HEADER_TOKEN);
test_simple("GET / HTTP/1.0\r\nHello: woooo\2rld\r\n\r\n", HPE_INVALID_HEADER_TOKEN);
// Extended characters - see nodejs/test/parallel/test-http-headers-obstext.js // Extended characters - see nodejs/test/parallel/test-http-headers-obstext.js
test_simple("GET / HTTP/1.1\r\n" test_simple("GET / HTTP/1.1\r\n"
"Test: Düsseldorf\r\n", "Test: Düsseldorf\r\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment