From 55128ae2638d4489d2858dd733e97efb7afbc76f Mon Sep 17 00:00:00 2001 From: Jessie Murray Date: Tue, 16 Nov 2021 12:26:50 -0800 Subject: [PATCH] Fix http_parser check for architectures with unsigned chars 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. --- src/http-parser/http_parser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/http-parser/http_parser.c b/src/http-parser/http_parser.c index 7823085..e461fba 100644 --- a/src/http-parser/http_parser.c +++ b/src/http-parser/http_parser.c @@ -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; @@ -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;