git: 72d7d152c2ff - main - bsnmp: drop messages with an unsupported SNMP version
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 24 Nov 2026 20:03:49 UTC
The branch main has been updated by gordon:
URL: https://cgit.FreeBSD.org/src/commit/?id=72d7d152c2ff4708928ae1f94b940b5528ba5013
commit 72d7d152c2ff4708928ae1f94b940b5528ba5013
Author: Gordon Tetlow <gordon@FreeBSD.org>
AuthorDate: 2026-11-23 20:41:55 +0000
Commit: Gordon Tetlow <gordon@FreeBSD.org>
CommitDate: 2026-11-24 20:02:28 +0000
bsnmp: drop messages with an unsupported SNMP version
snmp_pdu_decode_header() returned SNMP_CODE_BADENC for an unknown
version. snmp_input_start() treats BADENC as a bad value in a SET and
carries on, so its version check, which runs only for SNMP_CODE_OK, was
skipped. The message then reached snmp_pdu_auth_access(), which with
snmp_vacm loaded switched on pdu->version and called abort() for
SNMP_Verr. A single unauthenticated packet could stop bsnmpd.
Return SNMP_CODE_BADVERS instead, as bsnmplib(3) documents, so the
message is counted in snmpInBadVersions and dropped. Remove the
mapping in snmp_pdu_decode() that tried to do this but was never
reached, and have snmp_pdu_auth_access() deny an unknown version
rather than abort.
Reported by: Hila Cohen, Apiiro (hillalee on github)
Reviewed by: harti
MFC after: 3 days
---
contrib/bsnmp/lib/snmp.c | 6 +-----
contrib/bsnmp/snmpd/main.c | 2 +-
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/contrib/bsnmp/lib/snmp.c b/contrib/bsnmp/lib/snmp.c
index acdf5df0c683..7167e7686149 100644
--- a/contrib/bsnmp/lib/snmp.c
+++ b/contrib/bsnmp/lib/snmp.c
@@ -449,10 +449,6 @@ snmp_pdu_decode(struct asn_buf *b, struct snmp_pdu *pdu, int32_t *ip)
snmp_pdu_free(pdu);
break;
- case SNMP_CODE_BADENC:
- if (pdu->version == SNMP_Verr)
- return (SNMP_CODE_BADVERS);
-
default:
break;
}
@@ -497,7 +493,7 @@ snmp_pdu_decode_header(struct asn_buf *b, struct snmp_pdu *pdu)
else {
pdu->version = SNMP_Verr;
snmp_error("unsupported SNMP version");
- return (SNMP_CODE_BADENC);
+ return (SNMP_CODE_BADVERS);
}
if (pdu->version == SNMP_V3) {
diff --git a/contrib/bsnmp/snmpd/main.c b/contrib/bsnmp/snmpd/main.c
index 526fbb38b8f8..29086b4f26ad 100644
--- a/contrib/bsnmp/snmpd/main.c
+++ b/contrib/bsnmp/snmpd/main.c
@@ -412,7 +412,7 @@ snmp_pdu_auth_access(struct snmp_pdu *pdu, int32_t *ip)
break;
default:
- abort();
+ return (SNMP_CODE_FAILED);
}
SLIST_FOREACH(vuser, &vacm_userlist, vvu)