summaryrefslogtreecommitdiff
path: root/gethost.c
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremy@tifa.local>2008-01-10 21:15:56 -0800
committerJeremy Huddleston <jeremy@tifa.local>2008-01-10 21:15:56 -0800
commit65a0917d4661e370b50beed8f06f5577bfeea59f (patch)
tree66dbfdee1046ec9176db289d81803c7484770c7d /gethost.c
parent40e1769f4c631713c32c73a5244f3d65aea89ab7 (diff)
downloadxorg-app-xauth-65a0917d4661e370b50beed8f06f5577bfeea59f.tar.gz
get_address_info: don't allow duplicate entries to be returned in the list
OS-X's getaddrinfo() can return duplicate entries (and does for localhost with the default 10.5 /etc/hosts). This caused some annoying crashes which this patch takes care of. See http://trac.macosforge.org/projects/xquartz/ticket/44
Diffstat (limited to 'gethost.c')
-rw-r--r--gethost.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/gethost.c b/gethost.c
index a0f30da..94c1d99 100644
--- a/gethost.c
+++ b/gethost.c
@@ -307,7 +307,15 @@ struct addrlist *get_address_info (
family = FamilyInternet6;
}
- if (len > 0 && src != NULL) {
+ struct addrlist *duplicate;
+ for(duplicate = retval; duplicate != NULL; duplicate = duplicate->next) {
+ if(duplicate->family == family && duplicate->len == len &&
+ memcmp(duplicate->address, src, len) == 0) {
+ break;
+ }
+ }
+
+ if (len > 0 && src != NULL && duplicate == NULL) {
struct addrlist *newrv = malloc (sizeof(struct addrlist));
if (newrv) {
newrv->address = malloc (len);