[SNMP4J] Bug in OID class

Steffen Brüntjen Steffen.Bruentjen at macmon.eu
Mon Feb 6 17:17:35 CET 2017


Hi!

I found a problem in the OID class. The nextPeer() method runs into a StackOverflowError. The method:

  public final OID nextPeer() {
    OID next = new OID(this);
    if ((next.size() > 0) && (last() != MAX_SUBID_VALUE)) {
      next.set(next.size()-1, last()+1);
    }
    else if (next.size() > 1) {
      next.trim(1);
      next = nextPeer();
    }
    return next;
  }


The fix:

- next = nextPeer()
+ next = next.nextPeer();


Here's a test case:

  @Test
  public void testNextPeer() {
    OID oid = new OID(new int[] { 1, 0xFFFFFFFF });
    oid.nextPeer();
  }


Best regards,
Steffen Brüntjen



More information about the SNMP4J mailing list