2009-03-15 Aurelien Jarno * sysdeps/posix/getaddrinfo.c (getaddrinfo): correctly detect interface for all 127.X.Y.Z addresses. --- sysdeps/posix/getaddrinfo.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -2264,7 +2264,14 @@ tmp.addr[0] = 0; tmp.addr[1] = 0; tmp.addr[2] = htonl (0xffff); - tmp.addr[3] = sinp->sin_addr.s_addr; + /* Special case for lo interface, the source address + being possibly different than the interface + address. */ + if ((ntohl(sinp->sin_addr.s_addr) & 0xff000000) + == 0x7f000000) + tmp.addr[3] = htonl(0x7f000001); + else + tmp.addr[3] = sinp->sin_addr.s_addr; } else {