diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 1999-12-11 08:40:18 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 1999-12-11 08:40:18 +0000 |
commit | 6f2ee4f0686c644f7f60a27058137e92fda8bf5d (patch) | |
tree | 48ef0a8e5c6e484a75ea46b3e8df07d10cde6214 /lib/libc/net/gethostnamadr.c | |
parent | 00dfa6dd9d0c8d9b7025ff4a6286b58ceac9d337 (diff) |
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/net/gethostnamadr.c')
-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; } |