summaryrefslogtreecommitdiff
path: root/gethost.c
diff options
context:
space:
mode:
authorEgbert Eich <eich@freedesktop.org>2013-10-01 01:17:09 +0200
committerDr. Tilmann Bubeck <t.bubeck@reinform.de>2013-10-01 22:01:37 +0200
commit3be53072f8252962c6df740e64e897b970ae0349 (patch)
tree4907f1baeb9dff76004bb1f4fcc5ca5a5a405fed /gethost.c
parent58140dbbd39389ad6af58e201e055f3d4b92d368 (diff)
downloadxorg-app-xauth-3be53072f8252962c6df740e64e897b970ae0349.tar.gz
Handle v4-mapped inet6 addresses correctly
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@freedesktop.org>
Diffstat (limited to 'gethost.c')
-rw-r--r--gethost.c26
1 files 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;
}
}