[SNMP4J] Counter64 problem

Frank Fock fock at agentpp.com
Thu Feb 17 00:32:59 CET 2005


Hi Vincent,

You have discovered a bug. Please download v1.1.1 to fix
it. In class BER.java

    // check for leading  0 octet
    if (b == 0x00) {
      b = is.read();
      length--;
    }

should be replaced by:

    // check for leading  0 octet
    if (b == 0x00) {
      if (length > 1) {
        b = is.read();
      }
      length--;
    }

The bug was not discovered by our JUnit tests because also the encoding
of a Counter64 value was not optimal (used more bytes than necessary).

Best regards,
Frank


Vincent Rougier wrote:

> Hi,
>
> I was wondering if anybody has problem decoding Counter64 values ? I  
> have
> an exception on each try. Here is the dump I obtain :
>
> java.io.IOException: Unexpected end of input stream at position 58
> at org.snmp4j.asn1.BERInputStream.read(BERInputStream.java:57)
> at org.snmp4j.asn1.BER.decodeUnsignedInt64(BER.java:823)
> at org.snmp4j.smi.Counter64.decodeBER(Counter64.java:60)
> at org.snmp4j.smi.Variable.createFromBER(Variable.java:133)
> at org.snmp4j.smi.VariableBinding.decodeBER(VariableBinding.java:164)
> at org.snmp4j.PDU.decodeBER(PDU.java:413)
> at org.snmp4j.mp.MPv2c.prepareDataElements(MPv2c.java:172)
> at  
> org.snmp4j.MessageDispatcherImpl.dispatchMessage(MessageDispatcherImpl.j 
> ava:225)
> at  
> org.snmp4j.MessageDispatcherImpl.processMessage(MessageDispatcherImpl.ja 
> va:285)
> at  
> org.snmp4j.transport.DefaultUdpTransportMapping$ListenThread.run(Default 
> UdpTransportMapping.java:221)
>
>
>
> Ethereal on Linux decodes this Counter64 value, as well as snmpget from
> ucd-snmp (by the way, the content of this Counter is 0x46 0x01 0x00
> (Counter64, 1 byte, value 0)
>
> Thanks in advance for your help.
>
>
>
> Vincent
>
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
>





More information about the SNMP4J mailing list