Fix crash in ejabberd_c2s when blacklist hook returned true (thanks to Jonas Ådahl)

Cause of the crash jlib:ip_to_list/1 only supports IP tuples using the
form {N1,N2,N3,N4} which is not the case when IPv6 is enabled.
This commit is contained in:
Badlop 2010-11-02 14:04:10 +01:00
parent 91dee14ad6
commit 81546f3270
2 changed files with 4 additions and 4 deletions

View File

@ -243,8 +243,8 @@ init([{SockMod, Socket}, Opts, FSMLimitOpts]) ->
%% Check if IP is blacklisted:
case is_ip_blacklisted(IP) of
true ->
?INFO_MSG("Connection attempt from blacklisted IP: ~s",
[jlib:ip_to_list(IP)]),
?INFO_MSG("Connection attempt from blacklisted IP: ~s (~w)",
[jlib:ip_to_list(IP), IP]),
{stop, normal};
false ->
Socket1 =

View File

@ -387,8 +387,8 @@ e(X) -> exit({bad_encode_base64_token, X}).
%% Convert Erlang inet IP to list
ip_to_list({IP, _Port}) ->
ip_to_list(IP);
ip_to_list({A,B,C,D}) ->
lists:flatten(io_lib:format("~w.~w.~w.~w",[A,B,C,D])).
ip_to_list(IpTuple) when is_tuple(IpTuple) ->
inet_parse:ntoa(IpTuple).
% --------------------------------------------------------------------
% Compat layer.