docs/189268: 3 getaddrinfo(3) - hostanme="localhost", but it returns IN_ADDR_ANY (0.0.0.0)
Dreamcat4
dreamcat4 at gmail.com
Sat May 3 07:40:01 UTC 2014
The following reply was made to PR docs/189268; it has been noted by GNATS.
From: Dreamcat4 <dreamcat4 at gmail.com>
To: bug-followup at freebsd.org, dreamcat4 at gmail.com
Cc:
Subject: Re: docs/189268: 3 getaddrinfo(3) - hostanme="localhost",
but it returns IN_ADDR_ANY (0.0.0.0)
Date: Sat, 3 May 2014 08:29:44 +0100
--089e012953d0181fd904f879df3a
Content-Type: text/plain; charset=UTF-8
Ah,
I have researched a little more. It is my impression that the expected
result aught to be "::1" if the protocol family was PF_UNSPEC or PF_INET6.
Now that Allan has mentioned it. Commenting out the ::1 in /etc/hosts does
change the result. However that isn't something the gSOAP library which is
making that API call has any control over.
Also:
This bug occurs when the protocol family being requested is set to
"PF_UNSPEC" (unspecified). OR "PF_INET6". With the default "/etc/hosts"
file (where that ::1 localhost entry exists).
Wheras setting:
hints.ai_family = PF_INET;
returns 127.0.0.1 regardless of the ::1 in /etc/hosts file.
Setting:
hints.ai_family = PF_INET6;
also gives such incorrect "0.0.0.0", except if commenting out ::1 in
/etc/hosts as Alan says.
Then it gives:
getaddrinfo ~/ root~# gcc test.c -o test && ./test
getaddrinfo failed with code 8.
Which would be correct to error out since no corresponding ip6 address
found.
The gSOAP library seems to choose PF_UNSPEC because they want to support
both ipv4 and ipv6 protocols simultaneously (as many others also do). I'm
not sure if they could fix downstream the issue by avoiding PF_UNSPEC
because the bug will still occur on PF_INET6.
Anyway. Heres is the gSOAP code where getaddrinfo() is being called in
"soap_bind()":
http://sourceforge.net/p/gsoap2/code/HEAD/tree/gsoap/stdsoap2.cpp#l4789
http://sourceforge.net/p/gsoap2/code/HEAD/tree/gsoap/stdsoap2.cpp#l4791
Then later on in soap_bind() the incorrect address (0.0.0.0), is used are
the parameter being passed into bind()
http://sourceforge.net/p/gsoap2/code/HEAD/tree/gsoap/stdsoap2.cpp#l4876
--089e012953d0181fd904f879df3a
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><div>Ah,</div><div>I have researched a little more. I=
t is my impression that the expected result aught to be "::1" if =
the protocol family was PF_UNSPEC or PF_INET6.<br></div></div><div><br></di=
v>
Now that Allan has mentioned it. Commenting out the ::1 in /etc/hosts does =
change the result. However that isn't something the gSOAP library which=
is making that API call has any control over.<div><br></div><div>Also:</di=
v>
<div><br></div><div>This bug occurs when the protocol family being requeste=
d is set to "PF_UNSPEC" (unspecified). OR "PF_INET6". W=
ith the default "/etc/hosts" file (where that ::1 localhost entry=
exists).</div>
<div><br></div><div>Wheras setting:</div><div><br></div><div>hints.ai_famil=
y =C2=A0 =3D PF_INET;</div><div><br></div><div>returns 127.0.0.1 regardless=
of the ::1 in /etc/hosts file.</div><div><br></div><div>Setting:<br></div>=
<div>
<br></div><div><div>hints.ai_family =C2=A0 =3D PF_INET6;</div></div><div><b=
r></div><div>also gives such incorrect "0.0.0.0", except if comme=
nting out ::1 in /etc/hosts as Alan says.</div><div><br></div><div>Then it =
gives:</div>
<div><br></div><div><div>getaddrinfo ~/ root~# gcc test.c -o test &&=
; ./test</div><div>getaddrinfo failed with code 8.</div></div><div><br></di=
v><div>Which would be correct to error out since no corresponding ip6 addre=
ss found.</div>
<div><br></div><div><br></div><div>The gSOAP library seems to choose PF_UNS=
PEC because they want to support both ipv4 and ipv6 protocols simultaneousl=
y (as many others also do). I'm not sure if they could fix downstream t=
he issue by avoiding PF_UNSPEC because the bug will still occur on PF_INET6=
.<br>
</div><div><br></div><div><br></div><div>Anyway. Heres is the gSOAP code wh=
ere getaddrinfo() is being called in "soap_bind()":</div><div><br=
></div><div><a href=3D"http://sourceforge.net/p/gsoap2/code/HEAD/tree/gsoap=
/stdsoap2.cpp#l4789">http://sourceforge.net/p/gsoap2/code/HEAD/tree/gsoap/s=
tdsoap2.cpp#l4789</a><br>
</div><div><br></div><div><a href=3D"http://sourceforge.net/p/gsoap2/code/H=
EAD/tree/gsoap/stdsoap2.cpp#l4791">http://sourceforge.net/p/gsoap2/code/HEA=
D/tree/gsoap/stdsoap2.cpp#l4791</a><br></div><div><br></div><div>Then later=
on in soap_bind() the incorrect address (0.0.0.0), is used are the paramet=
er being passed into bind()</div>
<div><br></div><div><div><a href=3D"http://sourceforge.net/p/gsoap2/code/HE=
AD/tree/gsoap/stdsoap2.cpp#l4876">http://sourceforge.net/p/gsoap2/code/HEAD=
/tree/gsoap/stdsoap2.cpp#l4876</a><br></div></div><div><br></div><div><br>
</div></div>
--089e012953d0181fd904f879df3a--
More information about the freebsd-doc
mailing list