diff options
author | Badlop <badlop@process-one.net> | 2010-11-02 13:51:36 +0100 |
---|---|---|
committer | Badlop <badlop@process-one.net> | 2010-11-02 13:51:36 +0100 |
commit | 2d59efb515607f52e2495716b3cbf119dc86d964 (patch) | |
tree | 38a54f746052d71c9521a86b11074f7ecb2cdf6e /src | |
parent | Merge branch '2.1.x' of git+ssh://gitorious.process-one.net/ejabberd/mainline... (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/ejabberd_c2s.erl | 4 | ||||
-rw-r--r-- | src/jlib.erl | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index 260a89ad1..57baea334 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -196,8 +196,8 @@ init([{SockMod, Socket}, Opts]) -> %% 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 = diff --git a/src/jlib.erl b/src/jlib.erl index cbbdc3ce2..4adf8879e 100644 --- a/src/jlib.erl +++ b/src/jlib.erl @@ -797,5 +797,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({_,_,_,_,_,_,_,_} = Ipv6Address) -> + inet_parse:ntoa(Ipv6Address); +%% This function clause could use inet_parse too: ip_to_list({A,B,C,D}) -> lists:flatten(io_lib:format("~w.~w.~w.~w",[A,B,C,D])). |