[PATCH xauth] Handle v4-mapped inet6 addresses correctly
Egbert Eich
eich at freedesktop.org
Mon Sep 30 16:17:09 PDT 2013
Handling of v4-mapped inet6 addresses has been introduced
with commit 58140dbbd39389ad6af58e201e055f3d4b92d368:
Look for FamilyLocal if inet or inet6 address is loopback
These adresses should be treated as inet addresses. This patch
makes the code consistent with the handling if xcb_auth.c in
libxcb.
Signed-off-by: Egbert Eich <eich at freedesktop.org>
---
gethost.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/gethost.c b/gethost.c
index 48977bb..0a5aff5 100644
--- a/gethost.c
+++ b/gethost.c
@@ -245,17 +245,23 @@ struct addrlist *get_address_info (
} else if (ai->ai_family == AF_INET6) {
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)ai->ai_addr;
src = &(sin6->sin6_addr);
- if (IN6_IS_ADDR_V4MAPPED((const struct in6_addr *)src)
- || IN6_IS_ADDR_LOOPBACK((const struct in6_addr *)src)) {
- family = FamilyLocal;
- if (get_local_hostname (buf, sizeof buf)) {
- src = buf;
- len = strlen (buf);
- } else
- src = NULL;
+ if (!IN6_IS_ADDR_V4MAPPED((const struct in6_addr *)src)) {
+ if (IN6_IS_ADDR_LOOPBACK((const struct in6_addr *)src)) {
+ family = FamilyLocal;
+ if (get_local_hostname (buf, sizeof buf)) {
+ src = buf;
+ len = strlen (buf);
+ } else
+ src = NULL;
+ } else {
+ len = sizeof(sin6->sin6_addr);
+ family = FamilyInternet6;
+ }
} else {
- len = sizeof(sin6->sin6_addr);
- family = FamilyInternet6;
+ src = &(sin6->sin6_addr.s6_addr[12]);
+ len = sizeof(((struct sockaddr_in *)
+ ai->ai_addr)->sin_addr);
+ family = FamilyInternet;
}
}
--
1.8.1.4
More information about the xorg-devel
mailing list