This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Net - getaddrinfo() could return garbage in addresses
- From: Gary Thomas <gary at mlbassoc dot com>
- To: eCos patches <ecos-patches at sources dot redhat dot com>
- Date: 06 Mar 2003 19:15:22 -0700
- Subject: Net - getaddrinfo() could return garbage in addresses
Index: net/common/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos-opt/net/net/common/current/ChangeLog,v
retrieving revision 1.22
diff -u -5 -p -r1.22 ChangeLog
--- net/common/current/ChangeLog 5 Mar 2003 21:00:59 -0000 1.22
+++ net/common/current/ChangeLog 7 Mar 2003 02:14:09 -0000
@@ -1,5 +1,10 @@
+2003-03-06 Gary Thomas <gary at mlbassoc dot com>
+
+ * src/getaddrinfo.c: Need to clear any addresses - malloc() can
+ return garbage which the stack desn't like.
+
2003-03-05 Gary Thomas <gary at mlbassoc dot com>
* src/getaddrinfo.c: Allow getaddrinfo() to use DNS gethostbyXXX()
routines if DNS is present. Also, eliminate some debug messages.
Index: net/common/current/src/getaddrinfo.c
===================================================================
RCS file: /misc/cvsfiles/ecos-opt/net/net/common/current/src/getaddrinfo.c,v
retrieving revision 1.2
diff -u -5 -p -r1.2 getaddrinfo.c
--- net/common/current/src/getaddrinfo.c 5 Mar 2003 21:00:59 -0000 1.2
+++ net/common/current/src/getaddrinfo.c 7 Mar 2003 02:14:17 -0000
@@ -6,10 +6,11 @@
//
//==========================================================================
//####ECOSPDCOPYRIGHTBEGIN####
//
// Copyright (C) 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 2003 Gary Thomas
// All Rights Reserved.
//
// Permission is granted to use, copy, modify and redistribute this
// file.
//
@@ -52,10 +53,11 @@ _getaddr(struct addrinfo *ai, const char
switch (family) {
case AF_INET:
{
struct sockaddr_in *sa;
sa = (struct sockaddr_in *)malloc(sizeof(struct sockaddr_in));
+ memset(sa, 0, sizeof(*sa));
ai->ai_addr = (struct sockaddr *)sa;
ai->ai_addrlen = sizeof(*sa);
if (ai->ai_addr == (struct sockaddr *)NULL) {
return EAI_MEMORY;
}
@@ -84,10 +86,11 @@ _getaddr(struct addrinfo *ai, const char
#ifdef CYGPKG_NET_INET6
case AF_INET6:
{
struct sockaddr_in6 *sa;
sa = (struct sockaddr_in6 *)malloc(sizeof(struct sockaddr_in6));
+ memset(sa, 0, sizeof(*sa));
ai->ai_addr = (struct sockaddr *)sa;
ai->ai_addrlen = sizeof(*sa);
if (ai->ai_addr == (struct sockaddr *)NULL) {
return EAI_MEMORY;
}
--
------------------------------------------------------------
Gary Thomas |
MLB Associates | Consulting for the
+1 (970) 229-1963 | Embedded world
http://www.mlbassoc.com/ |
email: <gary at mlbassoc dot com> |
gpg: http://www.chez-thomas.org/gary/gpg_key.asc
------------------------------------------------------------