From dc314a3cb917e2f23680fa6b13ba4930d5f1b658 Mon Sep 17 00:00:00 2001 From: Jon Kolb Date: Fri, 10 Jun 2011 13:36:36 -0400 Subject: [PATCH] Return error when bad method starts with M or C --- http_parser.c | 4 ++++ test.c | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/http_parser.c b/http_parser.c index e8f5364..fc4f232 100644 --- a/http_parser.c +++ b/http_parser.c @@ -632,6 +632,8 @@ size_t http_parser_execute (http_parser *parser, parser->method = HTTP_CHECKOUT; } else if (index == 2 && ch == 'P') { parser->method = HTTP_COPY; + } else { + goto error; } } else if (parser->method == HTTP_MKCOL) { if (index == 1 && ch == 'O') { @@ -642,6 +644,8 @@ size_t http_parser_execute (http_parser *parser, parser->method = HTTP_MSEARCH; } else if (index == 2 && ch == 'A') { parser->method = HTTP_MKACTIVITY; + } else { + goto error; } } else if (index == 1 && parser->method == HTTP_POST && ch == 'R') { parser->method = HTTP_PROPFIND; /* or HTTP_PROPPATCH */ diff --git a/test.c b/test.c index 876cacf..34bbafb 100644 --- a/test.c +++ b/test.c @@ -1937,6 +1937,16 @@ main (void) test_simple(buf, 1); } + static const char *bad_methods[] = { + "C******", + "M****", + 0 }; + for (this_method = bad_methods; *this_method; this_method++) { + char buf[200]; + sprintf(buf, "%s / HTTP/1.1\r\n\r\n", *this_method); + test_simple(buf, 0); + } + const char *dumbfuck2 = "GET / HTTP/1.1\r\n" "X-SSL-Bullshit: -----BEGIN CERTIFICATE-----\r\n"