mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
ejabberd_http: Handle missing POST data gracefully
Return a "bad request" error instead of crashing if receiving POST/PUT data fails.
This commit is contained in:
parent
acab2270f1
commit
d4b4f35a0e
@ -396,7 +396,9 @@ extract_path_query(#state{request_method = Method,
|
||||
socket = _Socket} = State)
|
||||
when (Method =:= 'POST' orelse Method =:= 'PUT') andalso
|
||||
is_integer(Len) ->
|
||||
{NewState, Data} = recv_data(State, Len),
|
||||
case recv_data(State, Len) of
|
||||
error -> {State, false};
|
||||
{NewState, Data} ->
|
||||
?DEBUG("client data: ~p~n", [Data]),
|
||||
case catch url_decode_q_split(Path) of
|
||||
{'EXIT', _} -> {NewState, false};
|
||||
@ -408,6 +410,7 @@ extract_path_query(#state{request_method = Method,
|
||||
LQ -> LQ
|
||||
end,
|
||||
{NewState, {LPath, LQuery, Data}}
|
||||
end
|
||||
end;
|
||||
extract_path_query(State) ->
|
||||
{State, false}.
|
||||
@ -525,7 +528,7 @@ recv_data(State, Len, Acc) ->
|
||||
recv_data(State, Len - byte_size(Data), <<Acc/binary, Data/binary>>);
|
||||
Err ->
|
||||
?DEBUG("Cannot receive HTTP data: ~p", [Err]),
|
||||
<<"">>
|
||||
error
|
||||
end;
|
||||
_ ->
|
||||
Trail = (State#state.trail),
|
||||
|
Loading…
Reference in New Issue
Block a user