0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-16 05:00:24 +00:00

Fix two edge cases when the request-line provided is invalid

This commit is contained in:
Loïc Hoguin 2014-10-03 17:19:04 +03:00
parent 18f50b8697
commit 403895a641
2 changed files with 6 additions and 0 deletions

View file

@ -136,6 +136,8 @@ wait_request(Buffer, State=#state{socket=Socket, transport=Transport,
%% Empty lines must be using \r\n.
parse_request(<< $\n, _/binary >>, State, _) ->
error_terminate(400, State);
parse_request(<< $\s, _/bits >>, State, _) ->
error_terminate(400, State);
%% We limit the length of the Request-line to MaxLength to avoid endlessly
%% reading from the socket and eventually crashing.
parse_request(Buffer, State=#state{max_request_line_length=MaxLength,
@ -170,6 +172,8 @@ parse_method(<< C, Rest/bits >>, State, SoFar) ->
parse_uri(<< $\r, _/bits >>, State, _) ->
error_terminate(400, State);
parse_uri(<< $\s, _/bits >>, State, Method) ->
error_terminate(400, State);
parse_uri(<< "* ", Rest/bits >>, State, Method) ->
parse_version(Rest, State, Method, <<"*">>, <<>>);
parse_uri(<< "http://", Rest/bits >>, State, Method) ->