Hi,

some time ago, martinh@ fixed the PRs 6468 and 6071 in snmpd.
Unfortunately, that broke GETBULK support and nobody noticed.

GETBULK calls mps_getnextreq() multiple times and relies on the
incremented/updated OID in "o".  Without this diff, non-table OIDs
were not incremented and returned multiple times in a single GETBULK
response.

I also tested the bug reports from the old PRs and this diff does not
reintroduce their bugs.

OK?

Reyk

Index: mps.c
===================================================================
RCS file: /cvs/src/usr.sbin/snmpd/mps.c,v
retrieving revision 1.17
diff -u -p -u -p -r1.17 mps.c
--- mps.c       1 Oct 2012 11:36:55 -0000       1.17
+++ mps.c       1 Oct 2013 20:51:47 -0000
@@ -210,16 +210,11 @@ mps_getnextreq(struct ber_element *root,
                        break;
                }
        } else if (o->bo_n == value->o_oidlen && value->o_get != NULL) {
-               /* No instance identifier specified. Append .0. */
-               if (o->bo_n + 1 > BER_MAX_OID_LEN)
-                       return (NULL);
-               ber = ber_add_noid(ber, o, o->bo_n + 1);
-               if ((ret = value->o_get(value, o, &ber)) != 0)
-                       return (NULL);
-               return (ber);
+               next = value;
+               goto appendzero;
        }
 
-getnext:
+ getnext:
        for (next = value; next != NULL;) {
                next = smi_next(next);
                if (next == NULL)
@@ -246,8 +241,11 @@ getnext:
                }
        } else {
                bcopy(&next->o_id, o, sizeof(*o));
-               ber = ber_add_noid(ber, &next->o_id,
-                   next->o_oidlen + 1);
+ appendzero:
+               /* No instance identifier specified. Append .0. */
+               if (o->bo_n + 1 > BER_MAX_OID_LEN)
+                       return (NULL);
+               ber = ber_add_noid(ber, o, ++o->bo_n);
                if ((ret = next->o_get(next, o, &ber)) != 0)
                        return (NULL);
        }

Reply via email to