When trying to resolve a hostname by getaddrinfo()
using some specific
settings, it will always return -EAI_NONAME (Name or service not known).
To reproduce this behavior, you need to request an IPv6 address with the
additional AF_V4MAPPED flag set from an non IPv6 capable hostname. If
you choose a IPv4/IPv6 capable hostname like
google.com, everything
works fine.
This patch is more or less a port [1][2] from the glibc and their behavior
for the AF_V4MAPPED flag. To test the bug you can use the following snippet.
---- 8< ----
int ret;
struct addrinfo* result;
struct addrinfo hints;
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_INET6;
hints.ai_flags = AI_V4MAPPED;
ret = getaddrinfo("test.com", NULL, &hints, &result);
printf("getaddrinfo(): %i", ret);
---- 8< ----
[1]
https://sourceware.org/git/?p=glibc.git;a=commit;f=sysdeps/posix/getaddrinf…
[2]
https://sourceware.org/git/?p=glibc.git;a=commit;f=sysdeps/posix/getaddrinf…
Signed-off-by: Alexander Wenzel <alexander.wenzel(a)qsc.de>
---
libc/inet/getaddrinfo.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)