summaryrefslogtreecommitdiffstats
path: root/contrib/bsnmp
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2017-01-06 03:54:26 +0000
committerngie <ngie@FreeBSD.org>2017-01-06 03:54:26 +0000
commitaf597073b5bbf55ca17841f8801952e9b5020a0f (patch)
tree8530921bea2d2ae369047e0f2814b87fb5acbbd4 /contrib/bsnmp
parent9cfdaa413124016e1c4857257d9f1862cd205805 (diff)
downloadFreeBSD-src-af597073b5bbf55ca17841f8801952e9b5020a0f.zip
FreeBSD-src-af597073b5bbf55ca17841f8801952e9b5020a0f.tar.gz
MFC r310873:
Guard against use-after-free after calling mibif_free(..) Set variables to NULL after calling free. Also, remove unnecessary if (x != NULL) checks before calling free(x)
Diffstat (limited to 'contrib/bsnmp')
-rw-r--r--contrib/bsnmp/snmp_mibII/mibII.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/contrib/bsnmp/snmp_mibII/mibII.c b/contrib/bsnmp/snmp_mibII/mibII.c
index 3719e00..a105398 100644
--- a/contrib/bsnmp/snmp_mibII/mibII.c
+++ b/contrib/bsnmp/snmp_mibII/mibII.c
@@ -707,10 +707,11 @@ mibif_free(struct mibif *ifp)
}
free(ifp->private);
- if (ifp->physaddr != NULL)
- free(ifp->physaddr);
- if (ifp->specmib != NULL)
- free(ifp->specmib);
+ ifp->private = NULL;
+ free(ifp->physaddr);
+ ifp->physaddr = NULL;
+ free(ifp->specmib);
+ ifp->specmib = NULL;
STAILQ_FOREACH(map, &mibindexmap_list, link)
if (map->mibif == ifp) {
@@ -745,8 +746,8 @@ mibif_free(struct mibif *ifp)
at = at1;
}
-
free(ifp);
+ ifp = NULL;
mib_if_number--;
mib_iftable_last_change = this_tick;
}
OpenPOWER on IntegriCloud