diff options
author | 1999-12-11 08:40:17 +0000 | |
---|---|---|
committer | 1999-12-11 08:40:17 +0000 | |
commit | a6d82630a88811f3c919936aa71c3268a3a15fee (patch) | |
tree | 4f7f1666a64aa0e516e4ee07596e997ed32b8c87 /lib/libc | |
parent | fix gethostbyname2(foo, AF_INET6). (diff) | |
download | wireguard-openbsd-a6d82630a88811f3c919936aa71c3268a3a15fee.tar.xz wireguard-openbsd-a6d82630a88811f3c919936aa71c3268a3a15fee.zip |
prevent bogus reverse query for 1.0.0.0.in-addr.arpa.
this occurs by mixing up ::1 as IPv6 auto-tunnel address like ::10.1.1.1.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/net/gethostnamadr.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/libc/net/gethostnamadr.c b/lib/libc/net/gethostnamadr.c index 64be28a3512..13a8eef8468 100644 --- a/lib/libc/net/gethostnamadr.c +++ b/lib/libc/net/gethostnamadr.c @@ -52,7 +52,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.38 1999/12/11 08:32:20 itojun Exp $"; +static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.39 1999/12/11 08:40:17 itojun Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -664,8 +664,6 @@ gethostbyaddr(addr, len, af) int len, af; { const u_char *uaddr = (const u_char *)addr; - static const u_char mapped[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0xff,0xff }; - static const u_char tunnelled[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0,0 }; int n, size, i; querybuf buf; register struct hostent *hp; @@ -682,11 +680,11 @@ gethostbyaddr(addr, len, af) } if (af == AF_INET6 && len == IN6ADDRSZ && - (!bcmp(uaddr, mapped, sizeof mapped) || - !bcmp(uaddr, tunnelled, sizeof tunnelled))) { + (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)uaddr) || + IN6_IS_ADDR_V4COMPAT((struct in6_addr *)uaddr))) { /* Unmap. */ - addr += sizeof mapped; - uaddr += sizeof mapped; + addr += IN6ADDRSZ - INADDRSZ; + uaddr += IN6ADDRSZ - INADDRSZ; af = AF_INET; len = INADDRSZ; } |