]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
daemon/interfaces-bsd: cap NetBSD aggregate port count
authorVincent Bernat <vincent@bernat.ch>
Sat, 9 May 2026 13:02:12 +0000 (15:02 +0200)
committerVincent Bernat <vincent@bernat.ch>
Sat, 9 May 2026 13:26:12 +0000 (15:26 +0200)
The buffer is sized for 24 agrportinfo entries. Clamp it explicitly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
src/daemon/interfaces-bsd.c

index 7761a643e11e696d30aa632bed9b3ff168d14092..cd9d3c04c1eb9b0023205dc2c21edf560afdf9fd 100644 (file)
@@ -166,7 +166,8 @@ ifbsd_check_bond(struct lldpd *cfg, struct interfaces_device_list *interfaces,
        master->type |= IFACE_BOND_T;
 #elif defined HOST_OS_NETBSD
        /* No max, we consider a maximum of 24 ports */
-       char buf[sizeof(struct agrportinfo) * 24] = {};
+#  define IFBSD_NETBSD_MAX_AGRPORTS 24
+       char buf[sizeof(struct agrportinfo) * IFBSD_NETBSD_MAX_AGRPORTS] = {};
        size_t buflen = sizeof(buf);
        struct agrreq ar = { .ar_version = AGRREQ_VERSION,
                .ar_cmd = AGRCMD_PORTLIST,
@@ -186,6 +187,8 @@ ifbsd_check_bond(struct lldpd *cfg, struct interfaces_device_list *interfaces,
                }
                return;
        }
+       if (apl->apl_nports > IFBSD_NETBSD_MAX_AGRPORTS)
+               apl->apl_nports = IFBSD_NETBSD_MAX_AGRPORTS;
        for (int i = 0; i < apl->apl_nports; i++, api++) {
                struct interfaces_device *slave;
                slave = interfaces_nametointerface(interfaces, api->api_ifname);