From schoenfr@aunt.gaertner.de  Sat Mar 14 11:35:37 1998
Return-Path: <schoenfr@aunt.gaertner.de>
Received: from elvis.sw.ods.com ([160.86.13.7]) by elo.sw.ods.com
	 with esmtp id m0yDuqP-0003A1C
	(Debian Smail-3.2.0.92 1997-Feb-9 #2); Sat, 14 Mar 1998 11:35:37 -0600 (CST)
Received: from spog.gaertner.de ([194.45.135.2]) by elvis.sw.ods.com
          (Netscape Mail Server v2.01) with ESMTP id AAA23176
          for <david@sw.ods.com>; Sat, 14 Mar 1998 11:35:34 -0500
Received: from aunt.gaertner.de (schoenfr@aunt.gaertner.de [194.45.135.102])
	by spog.gaertner.de (8.8.8/8.8.8/Nase) with ESMTP id SAA03780;
	Sat, 14 Mar 1998 18:35:22 +0100
Received: (from schoenfr@localhost)
	by aunt.gaertner.de (8.8.8/8.8.8) id SAA21209;
	Sat, 14 Mar 1998 18:35:17 +0100 (MET)
Date: Sat, 14 Mar 1998 18:35:17 +0100 (MET)
Message-Id: <199803141735.SAA21209@aunt.gaertner.de>
From: Erik Schoenfelder <schoenfr@gaertner.de>
To: David Engel <david@sw.ods.com>
CC: schoenw@ibr.cs.tu-bs.de (Juergen Schoenwaelder)
In-reply-to: <199803121915.UAA01699@henkell.ibr.cs.tu-bs.de> (message from
	Juergen Schoenwaelder on Thu, 12 Mar 1998 20:15:06 +0100)
Subject: Re: Bug#19225: snmpwalk segvs reading a 3com mib
Reply-to: schoenfr@gaertner.de
Status: RO
X-Status: A
Content-Length: 3946
Lines: 136

Hi,

David> Hi Erik,

Please let me clarify, that your mail reached schoenw@ibr.cs.tu-bs.de

>  To: Erik Schoenfelder <schoenw@ibr.cs.tu-bs.de>

which is Juergen Schoenwaelder address, and not mine, but he forwarded
the mail to me.


David> Here's a bug report I recently received.  I'm attaching the MIB
David> in question for your convenience.  FWIW, scotty 2.1.8 appeared
David> to read the MIB file just fine.

Thank you (and Giuliano P Procida <gpp10@cam.ac.uk>) very much for the
report (and the enclosed mib).  The cmu-parser is broken-by-design...

It will be fixed in the next release (a diff is FYI appended).

Should i send Giuliano P Procida an answer with the fix or will you
answer, because you forwarded it ?

							Erik

--
--- cmu-snmp-linux-3.5/snmplib/parse.c	Sat Oct 25 23:55:46 1997
+++ cmu-snmp-linux-3.6b1/snmplib/parse.c	Sat Mar 14 17:49:19 1998
@@ -51,7 +51,7 @@
 };
 
 /* use large token buffer in case of very long tokens: */
-#define MAXTC	1024
+#define MAXTC	10240
 struct tc {	/* textual conventions */
     int type;
     char descriptor[MAXTOKEN];
@@ -127,6 +127,7 @@
 #define DEFINITIONS 58
 #define END         59
 #define SEMI        60
+#define TRAP_TYPE   61
 
 struct tok {
 	char *name;			/* token name */
@@ -201,6 +202,7 @@
 	{ "(", sizeof ("(")-1, LEFTPAREN },
 	{ ")", sizeof (")")-1, RIGHTPAREN },
 	{ ",", sizeof (",")-1, COMMA },
+	{ "TRAP-TYPE", sizeof ("TRAP-TYPE")-1, TRAP_TYPE },
 	{ NULL }
 };
 
@@ -632,12 +634,14 @@
     struct subid oid[MAX_OID_LEN];
     struct node *np, *root, *oldnp = NULL;
 
+    bzero(oid, sizeof(oid));
+
     type = get_token(fp, token);
     if (type != EQUALS){
 	print_error("Bad format", token, type);
 	return 0;
     }
-    if ((length = getoid(fp, oid, 32)) != 0){
+    if ((length = getoid(fp, oid, MAX_OID_LEN)) != 0){
 	np = root = (struct node *)Malloc(sizeof(struct node));
 	bzero((char *)np, sizeof(struct node));
 	/*
@@ -1130,8 +1134,8 @@
 	free_node(np);
 	return 0;
     }
-    length = getoid(fp, oid, 32);
-    if (length > 1 && length <= 32){
+    length = getoid(fp, oid, MAX_OID_LEN);
+    if (length > 1 && length <= MAX_OID_LEN){
 	/* just take the last pair in the oid list */
 	if (oid[length - 2].label)
 	    strncpy(np->parent, oid[length - 2].label, MAXLABEL);
@@ -1585,9 +1589,27 @@
 	    goto skipget;
 	} else if (type == ENDOFFILE){
 	    break;
-	} else {
-	    print_error("Bad operator", (char *)NULL, type);
+	} else if (type == TRAP_TYPE){
+	  /* 
+	   * skip over trap-type lines like:
+	   *  label TRAP-TYPE    
+	   *	  ENTERPRISE		foo
+	   *	  VARIABLES		{ bar }
+	   *	  DESCRIPTION		"This trap ..."
+	   *	  ::=			42
+	   */	  
+	  while((type = get_token(fp, token)) != ENDOFFILE && type != EQUALS) 
+	    continue;
+	  if (type != EQUALS) {
+	    print_error ("Expected \"::=\"", NULL, type);
 	    return NULL;
+	  }
+	  if ((type = get_token (fp, token)) != NUMBER){
+	    print_error ("Expected integer", token, type);
+	  }
+	} else {
+	  print_error ("Bad operator", (char *)NULL, type);
+	  return NULL;
 	}
     }
 #ifdef TEST
--- cmu-snmp-linux-3.5/snmplib/parse.h	Wed Mar 26 00:32:53 1997
+++ cmu-snmp-linux-3.6b1/snmplib/parse.h	Fri Mar 13 00:48:40 1998
@@ -36,9 +36,9 @@
 #endif
 
 
-#define MAXLABEL	64	/* maximum characters in a label */
-#define MAXTOKEN	64	/* maximum characters in a token */
-#define MAXQUOTESTR	512	/* maximum characters in a quoted string */
+#define MAXLABEL	128	/* maximum characters in a label */
+#define MAXTOKEN	128	/* maximum characters in a token */
+#define MAXQUOTESTR	4096	/* maximum characters in a quoted string */
 
 
 
--- cmu-snmp-linux-3.5/man/variables.5	Thu Aug  8 22:02:05 1996
+++ cmu-snmp-linux-3.6b1/man/variables.5	Sat Mar 14 18:05:24 1998
@@ -62,5 +62,7 @@
 The parser of the
 .I "mib.txt"
 file is not expected to handle bizarre (although correct) interpretations of the ASN.1 notation.
+.br
+TRAP-TYPE macros in a mib are simply skipped and not used.
 
 

