]> The Tcpdump Group git mirrors - tcpdump/commitdiff
From Juergen Schoenwaelder <[email protected]> - fix for the
authorguy <guy>
Tue, 7 May 2002 07:39:05 +0000 (07:39 +0000)
committerguy <guy>
Tue, 7 May 2002 07:39:05 +0000 (07:39 +0000)
following problem:

According to the ASN.1 documents, OIDs of the form 2.100.3 are
correctly encoded as 0x0603813403.  tcpdump fails to properly
decode them - it displays the value 4.20.3 instead of 2.100.3.

print-snmp.c

index aa8d78f05037bd59e2d8806c3b6e75f50482f948..70127c6949275466ee7a0519e4793b3672440a1f 100644 (file)
@@ -58,7 +58,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.50 2001-09-17 22:16:53 fenner Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.51 2002-05-07 07:39:05 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -688,13 +688,17 @@ asn1_print(struct be *elem)
                        
                        /*
                         * first subitem encodes two items with 1st*OIDMUX+2nd
+                        * (see X.690:1997 clause 8.19 for the details)
                         */
                        if (first < 0) {
+                               int s;
                                if (!nflag)
                                        objp = mibroot;
                                first = 0;
-                               OBJ_PRINT(o/OIDMUX, first);
-                               o %= OIDMUX;
+                               s = o / OIDMUX;
+                               if (s > 2) s = 2;
+                               OBJ_PRINT(s, first);
+                               o -= s * OIDMUX;
                        }
                        OBJ_PRINT(o, first);
                        if (--first < 0)
@@ -875,16 +879,19 @@ static void smi_decode_oid(struct be *elem, unsigned int *oid,
            
                /*
                 * first subitem encodes two items with 1st*OIDMUX+2nd
+                * (see X.690:1997 clause 8.19 for the details)
                 */
                if (first < 0) {
                        first = 0;
                        if (*oidlen < oidsize) {
-                           oid[(*oidlen)++] = o/OIDMUX;
+                           oid[*oidlen] = o / OIDMUX;
+                           if (oid[*oidlen] > 2) oid[*oidlen] = 2;
                        }
-                       o %= OIDMUX;
+                       o -= oid[*oidlen] * OIDMUX;
+                       if (*oidlen < oidsize) (*oidlen)++;
                }
                if (*oidlen < oidsize) {
-                   oid[(*oidlen)++] = o;
+                       oid[(*oidlen)++] = o;
                }
                o = 0;
        }