Ethereal-dev: [ethereal-dev] packet-snmp.c patch to handle zero length context names

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Juergen Schoenwaelder <schoenw@xxxxxxxxxxxxxxx>
Date: Wed, 28 Jun 2000 22:54:09 +0200
This following prevents a core dump when you dissect SNMPv3 packets
with a zero-length context name (which is legal according to RFC
2572).

[Also note that a context name can contain arbitrary octets including
 \0. The %s format specifier thus does not return useful results in
 all possible cases.]

/js

Index: packet-snmp.c
===================================================================
RCS file: /cvsroot/ethereal/packet-snmp.c,v
retrieving revision 1.38
diff -u -r1.38 packet-snmp.c
--- packet-snmp.c	2000/06/25 20:55:09	1.38
+++ packet-snmp.c	2000/06/28 20:50:50
@@ -1547,7 +1801,7 @@
 		}
 		if (snmp_tree) {
 			proto_tree_add_text(snmp_tree, NullTVB, offset, length,
-			    "Context Name: %s", cname);
+			    "Context Name: %s", cname ? cname : "");
 		}
 		g_free(cname);
 		offset += length;