summaryrefslogtreecommitdiff
path: root/xdmcp.c
diff options
context:
space:
mode:
authorAlan Coopersmith <Alan.Coopersmith@sun.com>2006-06-26 23:56:06 +0000
committerAlan Coopersmith <Alan.Coopersmith@sun.com>2006-06-26 23:56:06 +0000
commit6bf94d0ed871db12e8e5aa48200ce3b548895b8f (patch)
tree8c01bbf7b0b6352a353cdaf6e9485adb6b61bde6 /xdmcp.c
parentb80ae0aa74cfd9d168f4e100e0fea8fef240500f (diff)
Bugzilla #7332 <https://bugs.freedesktop.org/show_bug.cgi?id=7332> Patch
#6046 <https://bugs.freedesktop.org/attachment.cgi?id=6046> (1) Xdm compiled with IPv6 support failed to accept any chooser connections (even when only using IPv4). (2) There should be a one-to-one correspondence between successful getaddrinfo calls and freeaddrinfo calls. (Peter Breitenlohner)
Diffstat (limited to 'xdmcp.c')
-rw-r--r--xdmcp.c51
1 files changed, 35 insertions, 16 deletions
diff --git a/xdmcp.c b/xdmcp.c
index 8dc6815..bce632a 100644
--- a/xdmcp.c
+++ b/xdmcp.c
@@ -1,4 +1,4 @@
-/* $XdotOrg: app/xdm/xdmcp.c,v 1.5 2005/07/05 18:52:33 alanc Exp $ */
+/* $XdotOrg: app/xdm/xdmcp.c,v 1.6 2006/06/20 01:50:35 alanc Exp $ */
/* $Xorg: xdmcp.c,v 1.4 2001/02/09 02:05:41 xorgcvs Exp $ */
/*
@@ -578,8 +578,11 @@ NetworkAddressToName(
{
if (!strcmp (localhost, hostname))
{
- if (!getString (name, 10))
- return 0;
+ if (!getString (name, 10)) {
+ if (ai)
+ freeaddrinfo(ai);
+ return NULL;
+ }
sprintf (name, ":%d", displayNumber);
}
else
@@ -605,15 +608,21 @@ NetworkAddressToName(
}
}
- if (!getString (name, strlen (hostname) + 10))
- return 0;
+ if (!getString (name, strlen (hostname) + 10)) {
+ if (ai)
+ freeaddrinfo(ai);
+ return NULL;
+ }
sprintf (name, "%s:%d", hostname, displayNumber);
}
}
else
{
- if (!getString (name, INET6_ADDRSTRLEN + 10))
- return 0;
+ if (!getString (name, INET6_ADDRSTRLEN + 10)) {
+ if (ai)
+ freeaddrinfo(ai);
+ return NULL;
+ }
if (multiHomed) {
if (connectionType == FamilyInternet) {
data = (CARD8 *)
@@ -626,7 +635,9 @@ NetworkAddressToName(
}
if (inet_ntop(type, data, name, INET6_ADDRSTRLEN) == NULL) {
free(name);
- return 0;
+ if (ai)
+ freeaddrinfo(ai);
+ return NULL;
}
sprintf(name + strlen(name), ":%d", displayNumber);
}
@@ -1435,20 +1446,28 @@ NetworkAddressToHostname (
struct addrinfo *ai = NULL, *nai;
if (getaddrinfo(hostent->h_name, NULL, NULL, &ai) == 0) {
for (nai = ai; nai != NULL; nai = nai->ai_next) {
- if ((af_type == nai->ai_family) &&
- (connectionAddress->length == nai->ai_addrlen) &&
- (memcmp(connectionAddress->data,nai->ai_addr,
- nai->ai_addrlen) == 0) ) {
+ if ((af_type == nai->ai_family) && (
+ ((nai->ai_family == AF_INET) &&
+ (connectionAddress->length == sizeof(struct in_addr)) &&
+ (memcmp(connectionAddress->data,
+ &((struct sockaddr_in *)nai->ai_addr)->sin_addr,
+ connectionAddress->length) == 0)) ||
+ ((nai->ai_family == AF_INET6) &&
+ (connectionAddress->length == sizeof(struct in6_addr)) &&
+ (memcmp(connectionAddress->data,
+ &((struct sockaddr_in6 *)nai->ai_addr)->sin6_addr,
+ connectionAddress->length) == 0))))
break;
- }
}
- if (ai == NULL) {
+ if (nai == NULL) {
inet_ntop(af_type, connectionAddress->data,
dotted, sizeof(dotted));
- LogError("Possible DNS spoof attempt %s->%s.", dotted,
+ LogError("Possible DNS spoof attempt %s->%s.\n", dotted,
hostent->h_name);
hostent = NULL;
+ } else {
+ local_name = hostent->h_name;
}
freeaddrinfo(ai);
} else {
@@ -1459,7 +1478,7 @@ NetworkAddressToHostname (
if ((hostent = gethostbyname(s))) {
if (memcmp((char*)connectionAddress->data, hostent->h_addr,
hostent->h_length) != 0) {
- LogError("Possible DNS spoof attempt.");
+ LogError("Possible DNS spoof attempt.\n");
hostent = NULL; /* so it enters next if() */
} else {
local_name = hostent->h_name;