snmpd: skip getnext mib if OID_NOTSET

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

snmpd: skip getnext mib if OID_NOTSET

Martijn van Duren-5
Found this when testing getnext sysServices.
Without patch:
$ snmp get -On -v2c -cpublic 127.0.0.1 sysServices.0
.1.3.6.1.2.1.1.7.0 = No Such Object available on this agent at this OID
$ snmp getnext -On -v2c -cpublic 127.0.0.1 sysServices  
.1.3.6.1.2.1.1.7.0 = INTEGER: 0
$ snmp getnext -On -v2c -cpublic 127.0.0.1 .1.3.6.1.2.1.1.6.0
.1.3.6.1.2.1.1.8.0 = Timeticks: (0) 0:00:00.00

With patch:
$ snmp get -On -v2c -cpublic 127.0.0.1 sysServices.0        
.1.3.6.1.2.1.1.7.0 = No Such Object available on this agent at this OID
$ snmp getnext -On -v2c -cpublic 127.0.0.1 sysServices      
.1.3.6.1.2.1.1.8.0 = Timeticks: (0) 0:00:00.00
$ snmp getnext -On -v2c -cpublic 127.0.0.1 .1.3.6.1.2.1.1.6.0
.1.3.6.1.2.1.1.8.0 = Timeticks: (0) 0:00:00.00

OK?

martijn@

Index: mps.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/mps.c,v
retrieving revision 1.25
diff -u -p -r1.25 mps.c
--- mps.c 16 May 2019 05:00:00 -0000 1.25
+++ mps.c 14 Aug 2019 13:30:33 -0000
@@ -241,7 +245,8 @@ mps_getnextreq(struct snmp_message *msg,
  case 1: /* end-of-rows */
  break;
  }
- } else if (o->bo_n == value->o_oidlen && value->o_get != NULL) {
+ } else if (!OID_NOTSET(value) && o->bo_n == value->o_oidlen &&
+    value->o_get != NULL) {
  next = value;
  goto appendzero;
  }