diff options
author | Kristof Provost <kp@FreeBSD.org> | 2023-04-28 11:24:44 +0000 |
---|---|---|
committer | Kristof Provost <kp@FreeBSD.org> | 2023-04-28 12:27:11 +0000 |
commit | 95bc3ba7fec52dd410921544a597aebe8797d60a (patch) | |
tree | 15a2c01494e078baebd2e491dc92f457d5d0fa4f | |
parent | 020edaea2ab05c9cea7d83872f28a4e5e65407e2 (diff) | |
download | src-95bc3ba7fec52dd410921544a597aebe8797d60a.tar.gz src-95bc3ba7fec52dd410921544a597aebe8797d60a.zip |
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")
-rw-r--r-- | lib/libifconfig/libifconfig_carp.c | 2 |
1 files changed, 2 insertions, 0 deletions
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); |