summaryrefslogtreecommitdiff
path: root/packet-snmp.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2001-04-07 00:52:07 +0000
committerGuy Harris <guy@alum.mit.edu>2001-04-07 00:52:07 +0000
commit3d446c2609101c0d582179d1052ca0049ff0453e (patch)
tree601b23e610340f940b6d951351d3cd30b371fcf1 /packet-snmp.c
parentca49be4d3eae8c7ff17f07aa6b3b7122462ac80d (diff)
downloadwireshark-3d446c2609101c0d582179d1052ca0049ff0453e.tar.gz
Don't blow up if "asn1_string_value_decode()" supplies a null pointer as
the string because the string value is zero-length. Don't try to treat an agent address in a V1 trap as an IP address if it's not 4 bytes long. svn path=/trunk/; revision=3265
Diffstat (limited to 'packet-snmp.c')
-rw-r--r--packet-snmp.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/packet-snmp.c b/packet-snmp.c
index d1bd0658d0..fa6c994a4f 100644
--- a/packet-snmp.c
+++ b/packet-snmp.c
@@ -8,7 +8,7 @@
*
* See RFCs 1905, 1906, 1909, and 1910 for SNMPv2u.
*
- * $Id: packet-snmp.c,v 1.61 2001/04/06 23:12:33 guy Exp $
+ * $Id: packet-snmp.c,v 1.62 2001/04/07 00:52:07 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -834,7 +834,7 @@ snmp_variable_decode(proto_tree *snmp_tree, subid_t *variable_oid,
if (snmp_tree) {
#ifdef HAVE_SPRINT_VALUE
if (!unsafe) {
- variable.val.string = vb_octet_string;
+ variable.val.string = SAFE_STRING(vb_octet_string);
vb_display_string = format_var(&variable,
variable_oid, variable_oid_length, vb_type,
vb_length);
@@ -876,7 +876,8 @@ snmp_variable_decode(proto_tree *snmp_tree, subid_t *variable_oid,
} else {
proto_tree_add_text(snmp_tree, NullTVB, offset, length,
"Value: %s: %.*s", vb_type_name,
- (int)vb_length, vb_octet_string);
+ (int)vb_length,
+ SAFE_STRING(vb_octet_string));
}
}
g_free(vb_octet_string);
@@ -1124,8 +1125,17 @@ dissect_common_pdu(const u_char *pd, int offset, frame_data *fd,
}
length = asn1.pointer - start;
if (tree) {
- proto_tree_add_text(tree, NullTVB, offset, length,
- "Agent address: %s", ip_to_str(agent_address));
+ if (agent_address_length != 4) {
+ proto_tree_add_text(tree, NullTVB, offset,
+ length,
+ "Agent address: <length is %u, not 4>",
+ agent_address_length);
+ } else {
+ proto_tree_add_text(tree, NullTVB, offset,
+ length,
+ "Agent address: %s",
+ ip_to_str(agent_address));
+ }
}
g_free(agent_address);
offset += length;