[tkined] Re: decoding Object Ids

From: Juergen Schoenwaelder (schoenw@ibr.cs.tu-bs.de)
Date: Thu Nov 15 2001 - 19:59:01 MET


>>>>> Pete Flugstad writes:

Pete> I've got an agent that is sending out a trap with an object
Pete> identifier in it that like (among other things) { 6, 0 } or { 4,
Pete> 0 }. I'm the developer so I can change this (although the EMS
Pete> people will yell at me :-/).

Pete> Now, the SNMP library (Envoy) I'm working with does not seem to
Pete> have any problem encoding or decoding this correctly. And
Pete> NET-SNMP seems to decode it OK as well.

Pete> However, scotty stumbles on it. I see it get decoded like { 3,
Pete> 9, 112 } and other garbage deocodings.

Pete> In looking at this, the raw PDU seems to encode this as

Pete> 0x6 0x2 0x81 0x70

Pete> Where 0x6 is the OBJECT ID tag, 0x2 is the length, and 0x81 0x70
Pete> is the encoded value. Because the high-bit is on here, this
Pete> means the value get's extended, and it get's combined with the
Pete> next octet, so you end up with 0xF0. Which is decimal 240,
Pete> which is (6 * 40) + 0, which is correct I think.

Pete> scotty's problem is in TnmBerDecOID. Before I spend time trying
Pete> to fix this (not terribly hard I think), I expect that the { 6,
Pete> 0 } or { 4, 0 } is not valid, since only 0, 1, 2 are valid
Pete> values from the root. I expect because of the "special" way the
Pete> first two OIDs get encoded, there can be ambiguity in how to
Pete> decode it.

I think this is indeed the case. I do not have an ASN.1 standard handy
to verfy this, but there are comments in tnmAsn1.c in the OID encoder:

    /*
     * Check for a valid length. An OBJECT IDENTIFIER must have at
     * least two components and the first two values must fall into
     * the given ranges.
     */

    if ((oidLen < 2) || (oid[0] > 2 || oid[1] > 40)) {
        sprintf(error, "illegal OBJECT IDENTIFIER value");
        return NULL;
    }

So Tnm 3.0.x thinks 6.0 or 4.0 are invalid and usually this kind of
code does not appear without a reason.

If you really want to put an array of numbers into a single value, use
an OCTET STRING with fixed length number encodings.

/js

--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.



This archive was generated by hypermail 2b29 : Thu Jan 03 2002 - 14:56:28 MET