Libc getnameinfo length requirement
christophebeauval at hotmail.com
Thu Mar 1 22:44:17 UTC 2018
This message after having presented the problem below in the freenode
#freebsd and EFNet #bsdcode channels and being advised (amongst others)
to use this mailing list.
When I got strange errors (EAI_FAIL) from getnameinfo-calls in a private
project, I investigated the freebsd/libc/net/getnameinfo.c source code
and stumbled upon the requirement (in the switch-statement at line 127)
that the "socklen_t salen" argument needs to be the exact same number as
"sizeof(struct sockaddr_in)" for the PF_INET protocol family and
"sizeof(struct sockaddr_in6)" for the PF_INET6 protocol family. This
fails when using a "sockaddr_storage" struct as first argument and tied
to this a "sizeof(struct sockaddr_storage)" as second argument, as can
be found as example in RFC 4038 on page 21 paragraph 6.2.3. For the
PF_LOCAL protocol family a larger "salen" than it's used struct is also
not allowed in that switch.
A less strict requirement either allowing any larger size (like in
glibc's implementation) or at least the size of "struct
sockaddr_storage" (as suggested by hrs) would solve this problem.
More information about the freebsd-standards