Disallow empty Content-Length

PR-URL: https://github.com/nodejs/http-parser/pull/459
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
master
Olga Batyshkina 6 years ago committed by Ben Noordhuis
parent cd88eef772
commit 3502589659

@ -1740,6 +1740,11 @@ reexecute:
case h_transfer_encoding_chunked:
parser->flags |= F_CHUNKED;
break;
case h_content_length:
/* do not allow empty content length */
SET_ERRNO(HPE_INVALID_CONTENT_LENGTH);
goto error;
break;
default:
break;
}

@ -4182,6 +4182,13 @@ main (void)
test_invalid_header_field_token_error(HTTP_RESPONSE);
test_invalid_header_field_content_error(HTTP_RESPONSE);
test_simple_type(
"POST / HTTP/1.1\r\n"
"Content-Length:\r\n" // empty
"\r\n",
HPE_INVALID_CONTENT_LENGTH,
HTTP_REQUEST);
test_simple_type(
"POST / HTTP/1.1\r\n"
"Content-Length: 42 \r\n" // Note the surrounding whitespace.

Loading…
Cancel
Save