26
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-28 17:38:54 +01:00

Don't crash on malformed IP addresses

This commit is contained in:
Evgeniy Khramtsov 2017-02-28 13:11:49 +03:00
parent d81b07bd5f
commit ac74b7dca1

View File

@ -964,7 +964,7 @@ connect(AddrPorts, #{sockmod := SockMod} = State) ->
{ok, term(), ip_port()} | network_error(). {ok, term(), ip_port()} | network_error().
connect([{Addr, Port}|AddrPorts], SockMod, Timeout, _) -> connect([{Addr, Port}|AddrPorts], SockMod, Timeout, _) ->
Type = get_addr_type(Addr), Type = get_addr_type(Addr),
case SockMod:connect(Addr, Port, try SockMod:connect(Addr, Port,
[binary, {packet, 0}, [binary, {packet, 0},
{send_timeout, ?TCP_SEND_TIMEOUT}, {send_timeout, ?TCP_SEND_TIMEOUT},
{send_timeout_close, true}, {send_timeout_close, true},
@ -974,6 +974,8 @@ connect([{Addr, Port}|AddrPorts], SockMod, Timeout, _) ->
{ok, Socket, {Addr, Port}}; {ok, Socket, {Addr, Port}};
Err -> Err ->
connect(AddrPorts, SockMod, Timeout, Err) connect(AddrPorts, SockMod, Timeout, Err)
catch _:badarg ->
connect(AddrPorts, SockMod, Timeout, {error, einval})
end; end;
connect([], _SockMod, _Timeout, Err) -> connect([], _SockMod, _Timeout, Err) ->
Err. Err.