2 Replies Latest reply on Sep 4, 2006 3:25 PM by Heiko Rupp

    Wrong implementation of "compareOid" method in RequestHandle

    emailms box Newbie

      The implementation states in its Javadoc:

      @return 0 when equal, 1 if oid2 > oid1 and -1 if oid1>oid2

      However, the implementation is wrong in its code:

      int res;
      int nd1 = countDots(oid1);
      int nd2 = countDots(oid2);
      res = nd1 - nd2;
      if (res != 0) // different number of dots -> not equal
      return res;

      while it is true that a different number of dots means that OID(s) are not equal, it is most definitely NOT true that OID1 < OID2 if it is shorter. What matters is the VALUE of the FIRST non-matching OID component - e.g.:

      1.2.4.1.1 < 1.3.6 even though 1.3.6 is the shorter OID

      the correct implementation is to go component by component untill the first non-equal value is found. If one of the OID(s) is "exhausted" (i.e., it is a prefix of the other) then the shorter one comes first.

      This mis-implementation causes a BUG in SNMP GETNEXT behavior as it returns WRONG OID(s). In this context, "compareOid" should be used to find the first OID that is GREATER than the requested one and NOT less than - as is currently the (wrong) implementation of the "getNextOid" method.