aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/http_lib
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2011-05-12 14:06:12 +0200
committerMicael Karlberg <[email protected]>2011-05-12 14:06:12 +0200
commitd3d5b4fcf3e07c22e61c2c9a410d365178b12945 (patch)
treecf516c356a47991f1f7f136e0306c9812e738fff /lib/inets/src/http_lib
parent8a6b5ba7e038decf54e044656ef05ce9eec3c6dd (diff)
downloadotp-d3d5b4fcf3e07c22e61c2c9a410d365178b12945.tar.gz
otp-d3d5b4fcf3e07c22e61c2c9a410d365178b12945.tar.bz2
otp-d3d5b4fcf3e07c22e61c2c9a410d365178b12945.zip
Calling gen_tcp:connect with option {ip, {127,0,0,1}} results in an exit with
reason badarg. Neither SSL nor INETS catches this, resulting in crashes with incomprehensible reasons. OTP-9289
Diffstat (limited to 'lib/inets/src/http_lib')
-rw-r--r--lib/inets/src/http_lib/http_transport.erl30
1 files changed, 27 insertions, 3 deletions
diff --git a/lib/inets/src/http_lib/http_transport.erl b/lib/inets/src/http_lib/http_transport.erl
index 173911b868..8cabfe3c71 100644
--- a/lib/inets/src/http_lib/http_transport.erl
+++ b/lib/inets/src/http_lib/http_transport.erl
@@ -110,7 +110,17 @@ connect(ip_comm = _SocketType, {Host, Port}, Opts0, Timeout)
Opts = [binary, {packet, 0}, {active, false}, {reuseaddr, true} | Opts0],
?hlrt("connect using gen_tcp",
[{host, Host}, {port, Port}, {opts, Opts}, {timeout, Timeout}]),
- gen_tcp:connect(Host, Port, Opts, Timeout);
+ try gen_tcp:connect(Host, Port, Opts, Timeout) of
+ {ok, _} = OK ->
+ OK;
+ {error, _} = ERROR ->
+ ERROR
+ catch
+ exit:{badarg, _} ->
+ {error, {eoptions, Opts}};
+ exit:badarg ->
+ {error, {eoptions, Opts}}
+ end;
%% Wrapper for backaward compatibillity
connect({ssl, SslConfig}, Address, Opts, Timeout) ->
@@ -123,7 +133,14 @@ connect({ossl, SslConfig}, {Host, Port}, _, Timeout) ->
{port, Port},
{ssl_config, SslConfig},
{timeout, Timeout}]),
- ssl:connect(Host, Port, Opts, Timeout);
+ case (catch ssl:connect(Host, Port, Opts, Timeout)) of
+ {'EXIT', Reason} ->
+ {error, {eoptions, Reason}};
+ {ok, _} = OK ->
+ OK;
+ {error, _} = ERROR ->
+ ERROR
+ end;
connect({essl, SslConfig}, {Host, Port}, _, Timeout) ->
Opts = [binary, {active, false}, {ssl_imp, new}] ++ SslConfig,
@@ -132,7 +149,14 @@ connect({essl, SslConfig}, {Host, Port}, _, Timeout) ->
{port, Port},
{ssl_config, SslConfig},
{timeout, Timeout}]),
- ssl:connect(Host, Port, Opts, Timeout).
+ case (catch ssl:connect(Host, Port, Opts, Timeout)) of
+ {'EXIT', Reason} ->
+ {error, {eoptions, Reason}};
+ {ok, _} = OK ->
+ OK;
+ {error, _} = ERROR ->
+ ERROR
+ end.
%%-------------------------------------------------------------------------