diff options
-rw-r--r-- | usr.sbin/snmpd/mps.c | 17 | ||||
-rw-r--r-- | usr.sbin/snmpd/smi.c | 8 |
2 files changed, 21 insertions, 4 deletions
diff --git a/usr.sbin/snmpd/mps.c b/usr.sbin/snmpd/mps.c index 9d12def1d5e..56e7619c10b 100644 --- a/usr.sbin/snmpd/mps.c +++ b/usr.sbin/snmpd/mps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mps.c,v 1.25 2019/05/16 05:00:00 martijn Exp $ */ +/* $OpenBSD: mps.c,v 1.26 2019/10/03 12:00:40 martijn Exp $ */ /* * Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org> @@ -208,7 +208,20 @@ mps_getnextreq(struct snmp_message *msg, struct ber_element *root, bzero(&key, sizeof(key)); bcopy(o, &key.o_id, sizeof(struct ber_oid)); smi_oidlen(&key.o_id); /* Strip off any trailing .0. */ - value = smi_nfind(&key); + do { + value = smi_find(&key); + if (value->o_flags == 0) + value = NULL; + if (key.o_id.bo_n != 0) + key.o_id.bo_n--; + } while (value == NULL && key.o_id.bo_n > 0); + if (value == NULL || !(value->o_flags & OID_REGISTERED)) { + bcopy(o, &key.o_id, sizeof(struct ber_oid)); + smi_oidlen(&key.o_id); /* Strip off any trailing .0. */ + value = smi_nfind(&key); + while (value != NULL && value->o_flags == 0) + value = smi_nfind(value); + } if (value == NULL) goto fail; diff --git a/usr.sbin/snmpd/smi.c b/usr.sbin/snmpd/smi.c index d50d5da7884..447552224c3 100644 --- a/usr.sbin/snmpd/smi.c +++ b/usr.sbin/snmpd/smi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smi.c,v 1.24 2019/05/16 05:00:00 martijn Exp $ */ +/* $OpenBSD: smi.c,v 1.25 2019/10/03 12:00:40 martijn Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org> @@ -244,7 +244,11 @@ smi_find(struct oid *oid) struct oid * smi_nfind(struct oid *oid) { - return (RB_NFIND(oidtree, &smi_oidtree, oid)); + struct oid *n; + n = RB_NFIND(oidtree, &smi_oidtree, oid); + if (smi_oid_cmp(oid, n) == 0) + n = RB_NEXT(oidtree, &smi_oidtree, n); + return n; } struct oid * |