Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Commit

Permalink
Update misleading comment.
Browse files Browse the repository at this point in the history
The HTTP_MAX_HEADER_SIZE check is not there to guard against
buffer overflows, it's there to protect unwitting embedders
against denial-of-service attacks.
  • Loading branch information
bnoordhuis committed Oct 21, 2013
1 parent 3cbd13d commit f5c779b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion http_parser.c
Expand Up @@ -634,7 +634,17 @@ size_t http_parser_execute (http_parser *parser,

if (PARSING_HEADER(parser->state)) {
++parser->nread;
/* Buffer overflow attack */
/* Don't allow the total size of the HTTP headers (including the status
* line) to exceed HTTP_MAX_HEADER_SIZE. This check is here to protect
* embedders against denial-of-service attacks where the attacker feeds
* us a never-ending header that the embedder keeps buffering.
*
* This check is arguably the responsibility of embedders but we're doing
* it on the embedder's behalf because most won't bother and this way we
* make the web a little safer. HTTP_MAX_HEADER_SIZE is still far bigger
* than any reasonable request or response so this should never affect
* day-to-day operation.
*/
if (parser->nread > HTTP_MAX_HEADER_SIZE) {
SET_ERRNO(HPE_HEADER_OVERFLOW);
goto error;
Expand Down

0 comments on commit f5c779b

Please sign in to comment.