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).
event_stream
Cliff Frey 15 years ago committed by Ryan Dahl
parent 9eac636531
commit 6533f8ac9c

@ -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) {

Loading…
Cancel
Save