From: Alexandra Ellwood Date: Mon, 19 Mar 2007 20:21:54 +0000 (+0000) Subject: Zero sockaddrs in fai_add_entry() so we can compare them with memcmp() X-Git-Tag: krb5-1.7-alpha1~1250 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=aa09c20faed6ef91261b4ae6a97d3bca985b67ec;p=krb5.git Zero sockaddrs in fai_add_entry() so we can compare them with memcmp() If we don't zero the struct sockaddrs in fai_add_entry() then any sin_zero fields will be left as random memory and the memcmp() will return that the addresses are different even if they aren't. ticket: new target_version: 1.6.1 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19235 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/util/support/fake-addrinfo.c b/src/util/support/fake-addrinfo.c index 2cd8d92c3..8ebf19564 100644 --- a/src/util/support/fake-addrinfo.c +++ b/src/util/support/fake-addrinfo.c @@ -545,6 +545,7 @@ static inline int fai_add_entry (struct addrinfo **result, void *addr, sin4 = malloc (sizeof (struct sockaddr_in)); if (sin4 == 0) return EAI_MEMORY; + memset (sin4, 0, sizeof (struct sockaddr_in)); /* for sin_zero */ n->ai_addr = (struct sockaddr *) sin4; sin4->sin_family = AF_INET; sin4->sin_addr = *(struct in_addr *)addr; @@ -559,6 +560,7 @@ static inline int fai_add_entry (struct addrinfo **result, void *addr, sin6 = malloc (sizeof (struct sockaddr_in6)); if (sin6 == 0) return EAI_MEMORY; + memset (sin6, 0, sizeof (struct sockaddr_in6)); /* for sin_zero */ n->ai_addr = (struct sockaddr *) sin6; sin6->sin6_family = AF_INET6; sin6->sin6_addr = *(struct in6_addr *)addr;