git: 95bc3ba7fec5 - main - libifconfig: fix incorrect carp output
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 28 Apr 2023 12:27:24 UTC
The branch main has been updated by kp:
URL: https://cgit.FreeBSD.org/src/commit/?id=95bc3ba7fec52dd410921544a597aebe8797d60a
commit 95bc3ba7fec52dd410921544a597aebe8797d60a
Author: Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2023-04-28 11:24:44 +0000
Commit: Kristof Provost <kp@FreeBSD.org>
CommitDate: 2023-04-28 12:27:11 +0000
libifconfig: fix incorrect carp output
If one interface has a carp address configured on it ifconfig would show
this information on all interfaces.
That's because the kernel does (as one would expect) not return any carp
data for interface without carp configuration. However, this wound up
not overwriting the data passed in by the caller, and leaving the (now
stale) information in pace. As a result the caller thought carp was
configured on the interface.
Zero out the input structure before making the call to the kernel, so
that we correctly return 0 if there is no carp configuration on the
queried interface.
Sponsored by: Rubicon Communications, LLC ("Netgate")
---
lib/libifconfig/libifconfig_carp.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/libifconfig/libifconfig_carp.c b/lib/libifconfig/libifconfig_carp.c
index 501ca81782eb..2b612f0ba51b 100644
--- a/lib/libifconfig/libifconfig_carp.c
+++ b/lib/libifconfig/libifconfig_carp.c
@@ -77,6 +77,8 @@ _ifconfig_carp_get(ifconfig_handle_t *h, const char *name,
ifconfig_error_clear(h);
+ bzero(carp, sizeof(*carp) * ncarp);
+
if (! snl_init(&ss, NETLINK_GENERIC)) {
ifconfig_error(h, NETLINK, ENOTSUP);
return (-1);