From d1ef9be53cb1203a00961bdf9200b933b5e2889d Mon Sep 17 00:00:00 2001 From: Johannes Weiss Date: Wed, 5 Feb 2020 15:04:35 +0000 Subject: [PATCH] update vendored code & attribute it correctly (#1382) Motivation: This updates all vendored code and also lets github know what's vendored code through `.gitattributes`. Modifications: - http_parser update - attribution Result: - better github stats - up to date software --- .gitattributes | 3 ++ Sources/CNIOHTTPParser/c_nio_http_parser.c | 43 +++++++++---------- .../include/c_nio_http_parser.h | 2 +- 3 files changed, 24 insertions(+), 24 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..67fb046b0 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +Sources/CNIOHTTPParser/* linguist-vendored +Sources/CNIOSHA1/* linguist-vendored +Sources/CNIOLinux/ifaddrs-* linguist-vendored diff --git a/Sources/CNIOHTTPParser/c_nio_http_parser.c b/Sources/CNIOHTTPParser/c_nio_http_parser.c index 847d10970..5c087996a 100644 --- a/Sources/CNIOHTTPParser/c_nio_http_parser.c +++ b/Sources/CNIOHTTPParser/c_nio_http_parser.c @@ -1260,9 +1260,9 @@ reexecute: switch (parser->header_state) { case h_general: { - size_t limit = data + len - p; - limit = MIN(limit, max_header_size); - while (p+1 < data + limit && TOKEN(p[1])) { + size_t left = data + len - p; + const char* pe = p + MIN(left, max_header_size); + while (p+1 < pe && TOKEN(p[1])) { p++; } break; @@ -1499,28 +1499,25 @@ reexecute: switch (h_state) { case h_general: - { - const char* p_cr; - const char* p_lf; - size_t limit = data + len - p; + { + size_t left = data + len - p; + const char* pe = p + MIN(left, max_header_size); - limit = MIN(limit, max_header_size); - - p_cr = (const char*) memchr(p, CR, limit); - p_lf = (const char*) memchr(p, LF, limit); - if (p_cr != NULL) { - if (p_lf != NULL && p_cr >= p_lf) - p = p_lf; - else - p = p_cr; - } else if (UNLIKELY(p_lf != NULL)) { - p = p_lf; - } else { - p = data + len; + for (; p != pe; p++) { + ch = *p; + if (ch == CR || ch == LF) { + --p; + break; + } + if (!lenient && !IS_HEADER_CHAR(ch)) { + SET_ERRNO(HPE_INVALID_HEADER_TOKEN); + goto error; + } + } + if (p == data + len) + --p; + break; } - --p; - break; - } case h_connection: case h_transfer_encoding: diff --git a/Sources/CNIOHTTPParser/include/c_nio_http_parser.h b/Sources/CNIOHTTPParser/include/c_nio_http_parser.h index db7bd5eb6..d08367750 100644 --- a/Sources/CNIOHTTPParser/include/c_nio_http_parser.h +++ b/Sources/CNIOHTTPParser/include/c_nio_http_parser.h @@ -30,7 +30,7 @@ extern "C" { /* Also update SONAME in the Makefile whenever you change these. */ #define HTTP_PARSER_VERSION_MAJOR 2 #define HTTP_PARSER_VERSION_MINOR 9 -#define HTTP_PARSER_VERSION_PATCH 0 +#define HTTP_PARSER_VERSION_PATCH 2 #include #if defined(_WIN32) && !defined(__MINGW32__) && \