Module Name:    src
Committed By:   christos
Date:           Fri Jan 24 17:26:18 UTC 2014

Modified Files:
        src/lib/libc/net: gethnamaddr.c

Log Message:
CID 1163170, 1164171, resource leak
CID 1161172 double free


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/lib/libc/net/gethnamaddr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/net/gethnamaddr.c
diff -u src/lib/libc/net/gethnamaddr.c:1.89 src/lib/libc/net/gethnamaddr.c:1.90
--- src/lib/libc/net/gethnamaddr.c:1.89	Fri Jan 17 07:39:47 2014
+++ src/lib/libc/net/gethnamaddr.c	Fri Jan 24 12:26:18 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: gethnamaddr.c,v 1.89 2014/01/17 12:39:47 drochner Exp $	*/
+/*	$NetBSD: gethnamaddr.c,v 1.90 2014/01/24 17:26:18 christos Exp $	*/
 
 /*
  * ++Copyright++ 1985, 1988, 1993
@@ -57,7 +57,7 @@
 static char sccsid[] = "@(#)gethostnamadr.c	8.1 (Berkeley) 6/4/93";
 static char rcsid[] = "Id: gethnamaddr.c,v 8.21 1997/06/01 20:34:37 vixie Exp ";
 #else
-__RCSID("$NetBSD: gethnamaddr.c,v 1.89 2014/01/17 12:39:47 drochner Exp $");
+__RCSID("$NetBSD: gethnamaddr.c,v 1.90 2014/01/24 17:26:18 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -199,18 +199,14 @@ debugprintf(const char *msg, res_state r
 #define BOUNDED_INCR(x) \
 	do { \
 		cp += (x); \
-		if (cp > eom) { \
-			h_errno = NO_RECOVERY; \
-			return NULL; \
-		} \
+		if (cp > eom) \
+			goto no_recovery; \
 	} while (/*CONSTCOND*/0)
 
 #define BOUNDS_CHECK(ptr, count) \
 	do { \
-		if ((ptr) + (count) > eom) { \
-			h_errno = NO_RECOVERY; \
-			return NULL; \
-		} \
+		if ((ptr) + (count) > eom) \
+			goto no_recovery; \
 	} while (/*CONSTCOND*/0)
 
 static struct hostent *
@@ -503,6 +499,7 @@ success:
 	hent->h_aliases = (void *)bp;
 	memcpy(bp, aliases, qlen);
 	free(aliases);
+	aliases = NULL;
 
 	bp += qlen;
 	n = (int)(hap - addr_ptrs);

Reply via email to