From 6533f8ac9c07b134b546223f5c0a7d5787bb333d Mon Sep 17 00:00:00 2001 From: Cliff Frey Date: Fri, 11 Jun 2010 17:19:48 -0700 Subject: [PATCH] do not access random memory before lowcase array This matters because char is signed by default on x86, so bytes with values above 127 could have theoretically survived a pass through lowcase (assuming that there was some non-zero data before the lowcase array). --- http_parser.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/http_parser.c b/http_parser.c index d02f295..432466f 100644 --- a/http_parser.c +++ b/http_parser.c @@ -77,7 +77,7 @@ do { \ #define CLOSE "close" -static const unsigned char lowcase[] = +static const char lowcase[256] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0-\0\0" "0123456789\0\0\0\0\0\0" "\0abcdefghijklmnopqrstuvwxyz\0\0\0\0_" @@ -977,7 +977,7 @@ size_t http_parser_execute (http_parser *parser, case s_header_field: { - c = lowcase[(int)ch]; + c = lowcase[(unsigned char)ch]; if (c) { switch (header_state) { @@ -1113,7 +1113,7 @@ size_t http_parser_execute (http_parser *parser, state = s_header_value; index = 0; - c = lowcase[(int)ch]; + c = lowcase[(unsigned char)ch]; if (!c) { if (ch == CR) { @@ -1174,7 +1174,7 @@ size_t http_parser_execute (http_parser *parser, case s_header_value: { - c = lowcase[(int)ch]; + c = lowcase[(unsigned char)ch]; if (!c) { if (ch == CR) {