X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_header_parser.c;h=5dfaeddfe8c9067c2a6393d82ed1a0d20b535d28;hp=e1ebe12cf503cc284e11e0ae9bd5315c14517887;hb=1f37d09e4c7f55cf6f2c3c10ea3ec2424a482671;hpb=f00dec5b0217c81cf9d71d96103106fdaf2ab310 diff --git a/php_http_header_parser.c b/php_http_header_parser.c index e1ebe12..5dfaedd 100644 --- a/php_http_header_parser.c +++ b/php_http_header_parser.c @@ -141,11 +141,14 @@ php_http_header_parser_state_t php_http_header_parser_parse(php_http_header_pars const char *colon, *eol_str = NULL; int eol_len = 0; + /* fix buffer here, so eol_str pointer doesn't become obsolete afterwards */ + php_http_buffer_fix(buffer); + if (buffer->data == (eol_str = php_http_locate_bin_eol(buffer->data, buffer->used, &eol_len))) { /* end of headers */ php_http_buffer_cut(buffer, 0, eol_len); php_http_header_parser_state_push(parser, 1, PHP_HTTP_HEADER_PARSER_STATE_DONE); - } else if (php_http_info_parse(&parser->info, php_http_buffer_fix(buffer)->data)) { + } else if (php_http_info_parse(&parser->info, buffer->data)) { /* new message starting with request/response line */ if (callback_func) { callback_func(callback_arg, &headers, &parser->info); @@ -171,7 +174,6 @@ php_http_header_parser_state_t php_http_header_parser_parse(php_http_header_pars php_http_header_parser_state_push(parser, 1, PHP_HTTP_HEADER_PARSER_STATE_VALUE); } else if (eol_str || (flags & PHP_HTTP_HEADER_PARSER_CLEANUP)) { /* neither reqeust/response line nor 'header:' string, or injected new line or NUL etc. */ - php_http_buffer_fix(buffer); php_http_header_parser_error(strspn(buffer->data, PHP_HTTP_HEADER_NAME_CHARS), buffer->data, buffer->used, eol_str); return php_http_header_parser_state_push(parser, 1, PHP_HTTP_HEADER_PARSER_STATE_FAILURE); } else {