Skip to content

Commit

Permalink
Return error when bad method starts with M or C
Browse files Browse the repository at this point in the history
  • Loading branch information
kolbyjack committed Jun 10, 2011
1 parent d34a2ad commit dc314a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions http_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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 */
Expand Down
10 changes: 10 additions & 0 deletions test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit dc314a3

Please sign in to comment.