diff options
author | itojun <> | 1999-12-11 08:40:17 +0000 |
---|---|---|
committer | itojun <> | 1999-12-11 08:40:17 +0000 |
commit | b7a3679a8644a459ff88c24c59a9c594331fe014 (patch) | |
tree | 4982d26b9e1057aa42a3dbe62b3b5c0471021b4d | |
parent | f5e469e28bc4486cb124f63ef4a9bc210f205e42 (diff) | |
download | openbsd-b7a3679a8644a459ff88c24c59a9c594331fe014.tar.gz openbsd-b7a3679a8644a459ff88c24c59a9c594331fe014.tar.bz2 openbsd-b7a3679a8644a459ff88c24c59a9c594331fe014.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.
-rw-r--r-- | src/lib/libc/net/gethostnamadr.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/lib/libc/net/gethostnamadr.c b/src/lib/libc/net/gethostnamadr.c index 64be28a351..13a8eef846 100644 --- a/src/lib/libc/net/gethostnamadr.c +++ b/src/lib/libc/net/gethostnamadr.c | |||
@@ -52,7 +52,7 @@ | |||
52 | */ | 52 | */ |
53 | 53 | ||
54 | #if defined(LIBC_SCCS) && !defined(lint) | 54 | #if defined(LIBC_SCCS) && !defined(lint) |
55 | static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.38 1999/12/11 08:32:20 itojun Exp $"; | 55 | static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.39 1999/12/11 08:40:17 itojun Exp $"; |
56 | #endif /* LIBC_SCCS and not lint */ | 56 | #endif /* LIBC_SCCS and not lint */ |
57 | 57 | ||
58 | #include <sys/param.h> | 58 | #include <sys/param.h> |
@@ -664,8 +664,6 @@ gethostbyaddr(addr, len, af) | |||
664 | int len, af; | 664 | int len, af; |
665 | { | 665 | { |
666 | const u_char *uaddr = (const u_char *)addr; | 666 | const u_char *uaddr = (const u_char *)addr; |
667 | static const u_char mapped[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0xff,0xff }; | ||
668 | static const u_char tunnelled[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0,0 }; | ||
669 | int n, size, i; | 667 | int n, size, i; |
670 | querybuf buf; | 668 | querybuf buf; |
671 | register struct hostent *hp; | 669 | register struct hostent *hp; |
@@ -682,11 +680,11 @@ gethostbyaddr(addr, len, af) | |||
682 | } | 680 | } |
683 | 681 | ||
684 | if (af == AF_INET6 && len == IN6ADDRSZ && | 682 | if (af == AF_INET6 && len == IN6ADDRSZ && |
685 | (!bcmp(uaddr, mapped, sizeof mapped) || | 683 | (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)uaddr) || |
686 | !bcmp(uaddr, tunnelled, sizeof tunnelled))) { | 684 | IN6_IS_ADDR_V4COMPAT((struct in6_addr *)uaddr))) { |
687 | /* Unmap. */ | 685 | /* Unmap. */ |
688 | addr += sizeof mapped; | 686 | addr += IN6ADDRSZ - INADDRSZ; |
689 | uaddr += sizeof mapped; | 687 | uaddr += IN6ADDRSZ - INADDRSZ; |
690 | af = AF_INET; | 688 | af = AF_INET; |
691 | len = INADDRSZ; | 689 | len = INADDRSZ; |
692 | } | 690 | } |