Date: Tue, 22 Nov 2022 19:12:14 GMT From: John Baldwin <jhb@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: f6fdf9214a65 - main - systat: Fix a bunch of use after frees in fetch_ifstat(). Message-ID: <202211221912.2AMJCEjF081878@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=f6fdf9214a657351e78c68aac1888e674c0481f6 commit f6fdf9214a657351e78c68aac1888e674c0481f6 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2022-11-22 19:11:42 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2022-11-22 19:11:42 +0000 systat: Fix a bunch of use after frees in fetch_ifstat(). I think this was probably just a typo. initifstat() continues around a similar loop if the mib data fails to fetch, and fetch_ifstat() was already using a FOREACH_SAFE loop here so expected to keep going. Calling clearifstat() from the fetch routine also seems wrong, and the sort_interface_list() call triggered by the existing needsort = 1 will itself set needclear to trigger a future clearifstat(). Reported by: GCC 12 -Wuse-after-free Differential Revision: https://reviews.freebsd.org/D36823 --- usr.bin/systat/ifstat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.bin/systat/ifstat.c b/usr.bin/systat/ifstat.c index c97e586ae7a3..3ac230c77561 100644 --- a/usr.bin/systat/ifstat.c +++ b/usr.bin/systat/ifstat.c @@ -290,7 +290,7 @@ fetchifstat(void) SLIST_REMOVE(&curlist, ifp, if_stat, link); free(ifp); needsort = 1; - clearifstat(); + continue; } else if (strcmp(ifp->dev_name, ifp->if_mib.ifmd_name) != 0 ) { /* a device was removed and another one was added */ format_device_name(ifp);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202211221912.2AMJCEjF081878>