summaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2001-05-08 20:13:16 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2001-05-08 20:13:16 +0000
commit2aa4eeb9971262a7afcb15c66bb2840e2be2dc44 (patch)
treea109dccdff8bb0a486f73a8fd8e1da06afbb0650 /sys/netinet
parentac4cb4889f491b12145ae1b751a745e033a0afa3 (diff)
Fix realloc possible leak; this is userland, not kernel; reported by
Ted U <grendel@heorot.stanford.edu>.
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/ip_fil.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/netinet/ip_fil.c b/sys/netinet/ip_fil.c
index 920feb26b97..72e16b3b758 100644
--- a/sys/netinet/ip_fil.c
+++ b/sys/netinet/ip_fil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_fil.c,v 1.45 2001/05/08 20:02:59 fgsch Exp $ */
+/* $OpenBSD: ip_fil.c,v 1.46 2001/05/08 20:13:15 fgsch Exp $ */
/*
* Copyright (C) 1993-2001 by Darren Reed.
@@ -1643,7 +1643,7 @@ struct ifnet *get_unit(name, v)
char *name;
int v;
{
- struct ifnet *ifp, **ifa;
+ struct ifnet *ifp, **ifa, **nifneta;
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) || \
(defined(OpenBSD) && (OpenBSD >= 199603))
for (ifa = ifneta; ifa && (ifp = *ifa); ifa++) {
@@ -1673,12 +1673,14 @@ int v;
nifs = 1;
} else {
nifs++;
- ifneta = (struct ifnet **)realloc(ifneta,
+ nifneta = (struct ifnet **)realloc(ifneta,
(nifs + 1) * sizeof(*ifa));
- if (!ifneta) {
+ if (!nifneta) {
nifs = 0;
+ free(ifneta);
return NULL;
}
+ ifneta = nifneta;
ifneta[nifs] = NULL;
ifneta[nifs - 1] = (struct ifnet *)malloc(sizeof(*ifp));
if (!ifneta[nifs - 1]) {