From 24e2d2d43f55d5f53e3f5d6e0532b9ea55c74b20 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Sat, 15 Mar 2014 19:17:48 -0700 Subject: [PATCH] Allow HTTP_MAX_HEADER_SIZE to be defined externally --- http_parser.c | 2 +- http_parser.h | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/http_parser.c b/http_parser.c index 70cc9bd..df1b696 100644 --- a/http_parser.c +++ b/http_parser.c @@ -653,7 +653,7 @@ size_t http_parser_execute (http_parser *parser, * 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); goto error; } diff --git a/http_parser.h b/http_parser.h index ec61a12..d150f26 100644 --- a/http_parser.h +++ b/http_parser.h @@ -52,9 +52,16 @@ typedef unsigned __int64 uint64_t; # define HTTP_PARSER_STRICT 1 #endif -/* Maximium header size allowed */ -#define HTTP_MAX_HEADER_SIZE (80*1024) - +/* Maximium header size allowed. If the macro is not defined + * before including this header then the default is used. To + * change the maximum header size, define the macro in the build + * environment (e.g. -DHTTP_MAX_HEADER_SIZE=). To remove + * the effective limit on the size of the header, define the macro + * to a very large number (e.g. -DHTTP_MAX_HEADER_SIZE=0x7fffffff) + */ +#ifndef HTTP_MAX_HEADER_SIZE +# define HTTP_MAX_HEADER_SIZE (80*1024) +#endif typedef struct http_parser http_parser; typedef struct http_parser_settings http_parser_settings;