git: 9ee6278b7885 - main - netstat: fix double-free in netlink error code path.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 18 Mar 2023 14:02:55 UTC
The branch main has been updated by melifaro:
URL: https://cgit.FreeBSD.org/src/commit/?id=9ee6278b78859e8a9e303ec4a037b4e76d6ed89a
commit 9ee6278b78859e8a9e303ec4a037b4e76d6ed89a
Author: Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2023-03-18 14:01:46 +0000
Commit: Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2023-03-18 14:01:46 +0000
netstat: fix double-free in netlink error code path.
CID: 1504382
---
usr.bin/netstat/route_netlink.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/usr.bin/netstat/route_netlink.c b/usr.bin/netstat/route_netlink.c
index 3546603ca1cc..6e7e505c9619 100644
--- a/usr.bin/netstat/route_netlink.c
+++ b/usr.bin/netstat/route_netlink.c
@@ -91,10 +91,8 @@ prepare_ifmap_netlink(struct snl_state *ss, size_t *pifmap_size)
};
msg.hdr.nlmsg_len = sizeof(msg);
- if (!snl_send_message(ss, &msg.hdr)) {
- snl_free(ss);
+ if (!snl_send_message(ss, &msg.hdr))
return (NULL);
- }
struct ifmap_entry *ifmap = NULL;
uint32_t ifmap_size = 0;
@@ -286,6 +284,10 @@ p_rtable_netlink(int fibnum, int af)
return (false);
ifmap = prepare_ifmap_netlink(&ss, &ifmap_size);
+ if (ifmap == NULL) {
+ snl_free(&ss);
+ return (false);
+ }
struct {
struct nlmsghdr hdr;