Date: Thu, 1 Mar 2018 22:44:13 +0000 From: Christophe Beauval <christophebeauval@hotmail.com> To: "freebsd-standards@freebsd.org" <freebsd-standards@freebsd.org> Subject: Libc getnameinfo length requirement Message-ID: <VI1PR0402MB371177DFA52E8CC936FCDD00A2C60@VI1PR0402MB3711.eurprd04.prod.outlook.com>
index | next in thread | raw e-mail
Hello all 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. Kind regards Christophe Beauvalhome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?VI1PR0402MB371177DFA52E8CC936FCDD00A2C60>
