summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorfgsch <fgsch@openbsd.org>2001-05-08 20:13:15 +0000
committerfgsch <fgsch@openbsd.org>2001-05-08 20:13:15 +0000
commit5ac82e3cfbfbd3a1fba6f38dfc4bf58fa4f5ea6f (patch)
tree703542beaf85ac863f5b2c01fda2b3b2883a5e3a /sys
parentWhen `dup-to if:addr' clause is used, be sure to rewrite the dest addr (diff)
downloadwireguard-openbsd-5ac82e3cfbfbd3a1fba6f38dfc4bf58fa4f5ea6f.tar.xz
wireguard-openbsd-5ac82e3cfbfbd3a1fba6f38dfc4bf58fa4f5ea6f.zip
Fix realloc possible leak; this is userland, not kernel; reported by
Ted U <grendel@heorot.stanford.edu>.
Diffstat (limited to 'sys')
-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]) {