Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/net CID 1163170, 1164171, resource leak



details:   https://anonhg.NetBSD.org/src/rev/e5f9f8891d09
branches:  trunk
changeset: 326285:e5f9f8891d09
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Jan 24 17:26:18 2014 +0000

description:
CID 1163170, 1164171, resource leak
CID 1161172 double free

diffstat:

 lib/libc/net/gethnamaddr.c |  17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)

diffs (49 lines):

diff -r 24cfc4f86ce2 -r e5f9f8891d09 lib/libc/net/gethnamaddr.c
--- a/lib/libc/net/gethnamaddr.c        Fri Jan 24 15:11:09 2014 +0000
+++ b/lib/libc/net/gethnamaddr.c        Fri Jan 24 17:26:18 2014 +0000
@@ -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 @@
 #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 @@
        hent->h_aliases = (void *)bp;
        memcpy(bp, aliases, qlen);
        free(aliases);
+       aliases = NULL;
 
        bp += qlen;
        n = (int)(hap - addr_ptrs);



Home | Main Index | Thread Index | Old Index