Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong ssl ipv6 check #159

Open
stofel opened this issue Jan 20, 2018 · 3 comments
Open

Wrong ssl ipv6 check #159

stofel opened this issue Jan 20, 2018 · 3 comments

Comments

@stofel
Copy link

stofel commented Jan 20, 2018

ibrowse_http_client.erl line 615 is_ipv6_host(Host) use inet_parse:address(Host) which always return {error,einval}
For host with ipv4 and ipv6 resolving to ipv6 by default, but if ssl compiled without ipv6, ibrowse dosnt work

@cmullaparthi
Copy link
Owner

@stofel thanks for reporting this. I'm not sure I understand. Do you have an example to explain the problem please?

@stofel
Copy link
Author

stofel commented Jan 22, 2018

[alexs:bone:~]>erl
Erlang/OTP 19 [erts-8.3.5.4] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Eshell V8.3.5.4  (abort with ^G)
1> inet_parse:address("www.google.com").
{error,einval}
  1. Function inet_parse:address/1 used in ibrowse_http_client.erl line 615 for checking ipv6 and always return {error,einval}, it make ipv6 default for sites with ipv4 and ipv6
  2. is_ipv6_host not check ssl ipv6 support, witch not work by default, i don`t know why, maybe need some compile or start flags

I make patch is_ipv6_host(Host) for use ipv4 by default

ibrowse/src]>git diff ibrowse_http_client.erl
diff --git a/src/ibrowse_http_client.erl b/src/ibrowse_http_client.erl
index 2b79a0e..074e9c2 100644
--- a/src/ibrowse_http_client.erl
+++ b/src/ibrowse_http_client.erl
@@ -613,11 +613,8 @@ get_sock_options(Host, Options, SSLOptions) ->
     end.

 is_ipv6_host(Host) ->
-    case inet_parse:address(Host) of
-        {ok, {_, _, _, _, _, _, _, _}} ->
-            true;
-        {ok, {_, _, _, _}} ->
-            false;
+    case inet:gethostbyname(Host) of
+        {ok, #hostent{h_addrtype = inet}} -> false;
         _  ->
             case inet:gethostbyname(Host, inet6) of
                 {ok, #hostent{h_addrtype = inet6}} ->

@dch
Copy link
Contributor

dch commented Jul 4, 2018

BTW this was fixed by 555f707

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants