git: f53227d63591 - releng/15.1 - bsnmp: reject an oversized vacmViewTreeFamilyMask

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 17 Nov 2026 17:08:28 UTC
The branch releng/15.1 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=f53227d6359192733db6281ff66ef4315da181e8

commit f53227d6359192733db6281ff66ef4315da181e8
Author:     Maxim Konovalov <maxim@FreeBSD.org>
AuthorDate: 2026-11-13 03:07:48 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-11-16 21:25:03 +0000

    bsnmp: reject an oversized vacmViewTreeFamilyMask
    
    The SET handler for vacmViewTreeFamilyMask compared the value length
    against the 16-byte view->mask, but the check had no statement of its
    own: it guarded the following malloc() instead of rejecting the
    request.  A value longer than 16 bytes was therefore copied into
    view->mask with memcpy(), overflowing struct vacm_view.  Add the
    missing return so an over-long value is refused with wrongValue.
    
    Approved by:    so
    Security:       FreeBSD-SA-26:89.bsnmp
    Security:       CVE-2026-127743
    Reviewed by:    harti
    Fixes:          135f7de5ddb6
---
 contrib/bsnmp/snmp_vacm/vacm_snmp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/bsnmp/snmp_vacm/vacm_snmp.c b/contrib/bsnmp/snmp_vacm/vacm_snmp.c
index 39371176e493..29d1b8ffcb1e 100644
--- a/contrib/bsnmp/snmp_vacm/vacm_snmp.c
+++ b/contrib/bsnmp/snmp_vacm/vacm_snmp.c
@@ -490,6 +490,7 @@ op_vacm_view(struct snmp_context *ctx, struct snmp_value *val, uint32_t sub,
 		switch (val->var.subs[sub - 1]) {
 		case LEAF_vacmViewTreeFamilyMask:
 			if (val->v.octetstring.len > sizeof(view->mask))
+				return (SNMP_ERR_WRONG_VALUE);
 			ctx->scratch->ptr1 = malloc(sizeof(view->mask));
 			if (ctx->scratch->ptr1 == NULL)
 				return (SNMP_ERR_GENERR);