aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_protocol.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-10-03 17:19:04 +0300
committerLoïc Hoguin <[email protected]>2014-10-03 17:19:04 +0300
commit403895a6412001e30a09010d33e4c266bdb4fd09 (patch)
treebb4f579a04fe8645566e22c79ea9e3b04059c38a /src/cowboy_protocol.erl
parent18f50b869702c731324a3c47381ab1e0f3abb7f0 (diff)
downloadcowboy-403895a6412001e30a09010d33e4c266bdb4fd09.tar.gz
cowboy-403895a6412001e30a09010d33e4c266bdb4fd09.tar.bz2
cowboy-403895a6412001e30a09010d33e4c266bdb4fd09.zip
Fix two edge cases when the request-line provided is invalid
Diffstat (limited to 'src/cowboy_protocol.erl')
-rw-r--r--src/cowboy_protocol.erl4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/cowboy_protocol.erl b/src/cowboy_protocol.erl
index 82f1f38..8763baa 100644
--- a/src/cowboy_protocol.erl
+++ b/src/cowboy_protocol.erl
@@ -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) ->