Scanner problems
1) restore the scanner's original cursor position in case of insufficient input; 2) free the memories allocated for a new header in case of a failure. (cherry picked from commit 7a571f513e801f071873f2627400461b04213b13)
This commit is contained in:
parent
8bcc4b41d1
commit
2c663643dd
@ -357,6 +357,12 @@ Version 1.8.0
|
||||
Version 1.6.19
|
||||
*******************************************************************************
|
||||
|
||||
2013-09-02 Peng <howtofly(at)gmail.com>
|
||||
|
||||
1) restore the scanner's original cursor position in case of
|
||||
insufficient input;
|
||||
2) free the memories allocated for a new header in case of a failure.
|
||||
|
||||
2013-08-13 Peng <howtofly(at)gmail.com>
|
||||
|
||||
Patch to fix behaviou when char is signed
|
||||
|
@ -1459,6 +1459,8 @@ parse_status_t parser_parse_headers(INOUT http_parser_t *parser)
|
||||
/* check end of headers */
|
||||
status = scanner_get_token(scanner, &token, &tok_type);
|
||||
if (status != (parse_status_t)PARSE_OK) {
|
||||
/* pushback tokens; useful only on INCOMPLETE error */
|
||||
scanner->cursor = save_pos;
|
||||
return status;
|
||||
}
|
||||
switch (tok_type) {
|
||||
@ -1526,6 +1528,8 @@ parse_status_t parser_parse_headers(INOUT http_parser_t *parser)
|
||||
if (membuffer_assign(&header->name_buf, token.buf, token.length) ||
|
||||
membuffer_assign(&header->value, hdr_value.buf, hdr_value.length)) {
|
||||
/* not enough mem */
|
||||
membuffer_destroy(&header->value);
|
||||
membuffer_destroy(&header->name_buf);
|
||||
free(header);
|
||||
parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR;
|
||||
return PARSE_FAILURE;
|
||||
@ -1533,15 +1537,13 @@ parse_status_t parser_parse_headers(INOUT http_parser_t *parser)
|
||||
header->name.buf = header->name_buf.buf;
|
||||
header->name.length = header->name_buf.length;
|
||||
header->name_id = header_id;
|
||||
ListAddTail(&parser->msg.headers, header);
|
||||
/*NNS: ret = dlist_append( &parser->msg.headers, header ); */
|
||||
/** TODO: remove that? Yes as ret is not set anymore
|
||||
if (ret == UPNP_E_OUTOF_MEMORY) {
|
||||
parser->http_error_code =
|
||||
HTTP_INTERNAL_SERVER_ERROR;
|
||||
if (!ListAddTail(&parser->msg.headers, header)) {
|
||||
membuffer_destroy(&header->value);
|
||||
membuffer_destroy(&header->name_buf);
|
||||
free(header);
|
||||
parser->http_error_code = HTTP_INTERNAL_SERVER_ERROR;
|
||||
return PARSE_FAILURE;
|
||||
}
|
||||
end of remove that? */
|
||||
} else if (hdr_value.length > (size_t)0) {
|
||||
/* append value to existing header */
|
||||
/* append space */
|
||||
|
Loading…
x
Reference in New Issue
Block a user