Skip to content

Commit

Permalink
Fix http_parser check for architectures with unsigned chars
Browse files Browse the repository at this point in the history
http_parser.c has a table named "unhex" that it uses to convert hex
characters to their numeric values, e.g. 'F' -> 15. For non-hex
characters, the value is -1 but while the table contains int8_t values,
the extraction is done using a char. On ARMv8, char is *unsigned*, which
means it can't be compared to -1 as this is always false. Comparing to
(char)-1 instead will work.
  • Loading branch information
jessie-murray authored and nicolasff committed Nov 21, 2021
1 parent 74d4092 commit 55128ae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/http-parser/http_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ size_t http_parser_execute (http_parser *parser,
assert(parser->flags & F_CHUNKED);

c = unhex[(unsigned char)ch];
if (c == -1) goto error;
if (c == (char)-1) goto error;
parser->content_length = c;
state = s_chunk_size;
break;
Expand All @@ -1457,7 +1457,7 @@ size_t http_parser_execute (http_parser *parser,

c = unhex[(unsigned char)ch];

if (c == -1) {
if (c == (char)-1) {
if (ch == ';' || ch == ' ') {
state = s_chunk_parameters;
break;
Expand Down

0 comments on commit 55128ae

Please sign in to comment.