Remove HTTP_PARSER_DEBUG macro.

Remove the HTTP_PARSER_DEBUG macro for two reasons:

* It changes the size of struct http_parser, resulting in spurious memory
  corruption bugs if part of your application is built with HTTP_PARSER_DEBUG=1
  and other parts with HTTP_PARSER_DEBUG=0.

* It's a debugging tool for maintainers. It should never have been exposed in
  the API in the first place.
make-http-max-header-size-gyp-configurable
Ben Noordhuis 12 years ago
parent b4fc777dc6
commit 245f6f0078

@ -2,9 +2,9 @@ CC?=gcc
AR?=ar AR?=ar
CPPFLAGS += -I. CPPFLAGS += -I.
CPPFLAGS_DEBUG = $(CPPFLAGS) -DHTTP_PARSER_STRICT=1 -DHTTP_PARSER_DEBUG=1 CPPFLAGS_DEBUG = $(CPPFLAGS) -DHTTP_PARSER_STRICT=1
CPPFLAGS_DEBUG += $(CPPFLAGS_DEBUG_EXTRA) CPPFLAGS_DEBUG += $(CPPFLAGS_DEBUG_EXTRA)
CPPFLAGS_FAST = $(CPPFLAGS) -DHTTP_PARSER_STRICT=0 -DHTTP_PARSER_DEBUG=0 CPPFLAGS_FAST = $(CPPFLAGS) -DHTTP_PARSER_STRICT=0
CPPFLAGS_FAST += $(CPPFLAGS_FAST_EXTRA) CPPFLAGS_FAST += $(CPPFLAGS_FAST_EXTRA)
CFLAGS += -Wall -Wextra -Werror CFLAGS += -Wall -Wextra -Werror

@ -51,18 +51,10 @@
# define ELEM_AT(a, i, v) ((unsigned int) (i) < ARRAY_SIZE(a) ? (a)[(i)] : (v)) # define ELEM_AT(a, i, v) ((unsigned int) (i) < ARRAY_SIZE(a) ? (a)[(i)] : (v))
#endif #endif
#if HTTP_PARSER_DEBUG
#define SET_ERRNO(e) \ #define SET_ERRNO(e) \
do { \ do { \
parser->http_errno = (e); \ parser->http_errno = (e); \
parser->error_lineno = __LINE__; \
} while(0) } while(0)
#else
#define SET_ERRNO(e) \
do { \
parser->http_errno = (e); \
} while(0)
#endif
/* Run the notify callback FOR, returning ER if it fails */ /* Run the notify callback FOR, returning ER if it fails */

@ -51,14 +51,6 @@ typedef SSIZE_T ssize_t;
# define HTTP_PARSER_STRICT 1 # define HTTP_PARSER_STRICT 1
#endif #endif
/* Compile with -DHTTP_PARSER_DEBUG=1 to add extra debugging information to
* the error reporting facility.
*/
#ifndef HTTP_PARSER_DEBUG
# define HTTP_PARSER_DEBUG 0
#endif
/* Maximium header size allowed */ /* Maximium header size allowed */
#define HTTP_MAX_HEADER_SIZE (80*1024) #define HTTP_MAX_HEADER_SIZE (80*1024)
@ -196,13 +188,6 @@ enum http_errno {
/* Get an http_errno value from an http_parser */ /* Get an http_errno value from an http_parser */
#define HTTP_PARSER_ERRNO(p) ((enum http_errno) (p)->http_errno) #define HTTP_PARSER_ERRNO(p) ((enum http_errno) (p)->http_errno)
/* Get the line number that generated the current error */
#if HTTP_PARSER_DEBUG
#define HTTP_PARSER_ERRNO_LINE(p) ((p)->error_lineno)
#else
#define HTTP_PARSER_ERRNO_LINE(p) 0
#endif
struct http_parser { struct http_parser {
/** PRIVATE **/ /** PRIVATE **/
@ -229,10 +214,6 @@ struct http_parser {
*/ */
unsigned char upgrade : 1; unsigned char upgrade : 1;
#if HTTP_PARSER_DEBUG
uint32_t error_lineno;
#endif
/** PUBLIC **/ /** PUBLIC **/
void *data; /* A pointer to get hook to the "connection" or "socket" object */ void *data; /* A pointer to get hook to the "connection" or "socket" object */
}; };

@ -1954,8 +1954,7 @@ upgrade_message_fix(char *body, const size_t nread, const size_t nmsgs, ...) {
static void static void
print_error (const char *raw, size_t error_location) print_error (const char *raw, size_t error_location)
{ {
fprintf(stderr, "\n*** %s:%d -- %s ***\n\n", fprintf(stderr, "\n*** %s ***\n\n",
"http_parser.c", HTTP_PARSER_ERRNO_LINE(parser),
http_errno_description(HTTP_PARSER_ERRNO(parser))); http_errno_description(HTTP_PARSER_ERRNO(parser)));
int this_line = 0, char_len = 0; int this_line = 0, char_len = 0;

Loading…
Cancel
Save