Skip to content

Commit

Permalink
Include correct version in stream:stream when reporting errors
Browse files Browse the repository at this point in the history
This fixes issue #1174
  • Loading branch information
prefiks committed Jun 27, 2016
1 parent 75366ca commit 3446aba
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/ejabberd_c2s.erl
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,17 @@ wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
%% avoid possible DoS/flood attacks
<<"">>
end,
StreamVersion = case fxml:get_attr_s(<<"version">>, Attrs) of
<<"1.0">> ->
<<"1.0">>;
_ ->

This comment has been minimized.

Copy link
@SamWhited

SamWhited Jun 27, 2016

Should this case also happen if they explicitly advertise 0.9 (or does ejabberd even support 0.9)?

This comment has been minimized.

Copy link
@prefiks

prefiks Jun 27, 2016

Author Member

No, version attribute was only added in 1.0, in previous version not having it is the correct thing to do.

<<"">>
end,
IsBlacklistedIP = is_ip_blacklisted(StateData#state.ip, Lang),
case lists:member(Server, ?MYHOSTS) of
true when IsBlacklistedIP == false ->
change_shaper(StateData, jid:make(<<"">>, Server, <<"">>)),
case fxml:get_attr_s(<<"version">>, Attrs) of
case StreamVersion of
<<"1.0">> ->
send_header(StateData, Server, <<"1.0">>, DefaultLang),
case StateData#state.authenticated of
Expand Down Expand Up @@ -534,11 +540,11 @@ wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
{true, LogReason, ReasonT} = IsBlacklistedIP,
?INFO_MSG("Connection attempt from blacklisted IP ~s: ~s",
[jlib:ip_to_list(IP), LogReason]),
send_header(StateData, Server, <<"">>, DefaultLang),
send_header(StateData, Server, StreamVersion, DefaultLang),
send_element(StateData, ?POLICY_VIOLATION_ERR(Lang, ReasonT)),
{stop, normal, StateData};
_ ->
send_header(StateData, ?MYNAME, <<"">>, DefaultLang),
send_header(StateData, ?MYNAME, StreamVersion, DefaultLang),
send_element(StateData, ?HOST_UNKNOWN_ERR),
{stop, normal, StateData}
end;
Expand Down

0 comments on commit 3446aba

Please sign in to comment.