Fix parse failure observed with tvdevice sample.

Commit c40d2bc0c9 has a problem
at removing the parentheses in parser_parse_responseline.
Difference of pointers was used with intention, don't cast
them separately.
(cherry picked from commit 7178f300bb)
This commit is contained in:
Yoichi NAKAYAMA 2012-03-15 01:00:40 +09:00 committed by Marcelo Roberto Jimenez
parent 168444761d
commit cca16cbead
2 changed files with 13 additions and 4 deletions

View File

@ -318,6 +318,15 @@ Version 1.8.0
Version 1.6.16 Version 1.6.16
******************************************************************************* *******************************************************************************
2012-03-14 Yoichi NAKAYAMA <yoichi.nakayama(at)gmail.com>
Fix parse failure observed with tvdevice sample.
Commit c40d2bc0c9b60c43b641ac4669c7b8bbcd6134c5 has a problem
at removing the parentheses in parser_parse_responseline.
Difference of pointers was used with intention, don't cast
them separately.
2012-03-14 Yoichi NAKAYAMA <yoichi.nakayama(at)gmail.com> 2012-03-14 Yoichi NAKAYAMA <yoichi.nakayama(at)gmail.com>
Fix compile error on Windows. Fix compile error on Windows.

View File

@ -251,7 +251,7 @@ static parse_status_t scanner_get_token(
/* possibly more valid chars */ /* possibly more valid chars */
return PARSE_INCOMPLETE; return PARSE_INCOMPLETE;
/* calc token length */ /* calc token length */
token->length = (size_t)cursor - (size_t)token->buf; token->length = (size_t)(cursor - token->buf);
} else if (c == ' ' || c == '\t') { } else if (c == ' ' || c == '\t') {
token->buf = cursor++; token->buf = cursor++;
token_type = TT_WHITESPACE; token_type = TT_WHITESPACE;
@ -260,7 +260,7 @@ static parse_status_t scanner_get_token(
if (!scanner->entire_msg_loaded && cursor == null_terminator) if (!scanner->entire_msg_loaded && cursor == null_terminator)
/* possibly more chars */ /* possibly more chars */
return PARSE_INCOMPLETE; return PARSE_INCOMPLETE;
token->length = (size_t)cursor - (size_t)token->buf; token->length = (size_t)(cursor - token->buf);
} else if (c == TOKCHAR_CR) { } else if (c == TOKCHAR_CR) {
/* scan CRLF */ /* scan CRLF */
token->buf = cursor++; token->buf = cursor++;
@ -306,7 +306,7 @@ static parse_status_t scanner_get_token(
return PARSE_FAILURE; return PARSE_FAILURE;
} }
if (got_end_quote) if (got_end_quote)
token->length = (size_t)cursor - (size_t)token->buf; token->length = (size_t)(cursor - token->buf);
else { /* incomplete */ else { /* incomplete */
assert(cursor == null_terminator); assert(cursor == null_terminator);
@ -1416,7 +1416,7 @@ parse_status_t parser_parse_responseline(INOUT http_parser_t *parser)
while (*p == ' ' || *p == '\t') while (*p == ' ' || *p == '\t')
p++; p++;
/* now, p is at start of status msg */ /* now, p is at start of status msg */
n = line.length - (size_t)p - (size_t)line.buf; n = line.length - (size_t)(p - line.buf);
if (membuffer_assign(&hmsg->status_msg, p, n) != 0) { if (membuffer_assign(&hmsg->status_msg, p, n) != 0) {
/* out of mem */ /* out of mem */
parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR; parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR;