Update misleading comment.

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.
make-http-max-header-size-gyp-configurable
Ben Noordhuis 11 years ago
parent 3cbd13daca
commit f5c779bb85

@ -634,7 +634,17 @@ size_t http_parser_execute (http_parser *parser,
if (PARSING_HEADER(parser->state)) { if (PARSING_HEADER(parser->state)) {
++parser->nread; ++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) { if (parser->nread > HTTP_MAX_HEADER_SIZE) {
SET_ERRNO(HPE_HEADER_OVERFLOW); SET_ERRNO(HPE_HEADER_OVERFLOW);
goto error; goto error;

Loading…
Cancel
Save