From d357c745a6c55c17741d73669a138a175b3c8dd6 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Wed, 13 Apr 2005 21:20:23 +0000 Subject: In dissect_ber_octet_string_wcb(), make sure out_tvb is non-NULL before trying to use it so that we don't throw an assertion. Fixes bug 22. Do the same thing in dissect_ber_GeneralString(). svn path=/trunk/; revision=14065 --- epan/dissectors/packet-ber.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/epan/dissectors/packet-ber.c b/epan/dissectors/packet-ber.c index c1ce522086..4435fd86bd 100644 --- a/epan/dissectors/packet-ber.c +++ b/epan/dissectors/packet-ber.c @@ -506,10 +506,10 @@ printf("OCTET STRING dissect_ber_octet_string(%s) entered\n",name); int dissect_ber_octet_string_wcb(gboolean implicit_tag, packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, ber_callback func) { - tvbuff_t *out_tvb; + tvbuff_t *out_tvb = NULL; offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_id, (func)?&out_tvb:NULL); - if (func && (tvb_length(out_tvb)>0)) { + if (func && out_tvb && (tvb_length(out_tvb)>0)) { if (hf_id != -1) tree = proto_item_add_subtree(ber_last_created_item, ett_ber_octet_string); func(pinfo, tree, out_tvb, 0); @@ -1139,15 +1139,15 @@ printf("RESTRICTED STRING dissect_ber_octet_string(%s) entered\n",name); int dissect_ber_GeneralString(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_id, char *name_string, guint name_len) { - tvbuff_t *out_tvb; + tvbuff_t *out_tvb = NULL; offset = dissect_ber_restricted_string(FALSE, BER_UNI_TAG_GeneralString, pinfo, tree, tvb, offset, hf_id, (name_string)?&out_tvb:NULL); if (name_string) { - if (tvb_length(out_tvb) >= name_len) { + if (out_tvb && tvb_length(out_tvb) >= name_len) { tvb_memcpy(out_tvb, name_string, 0, name_len-1); name_string[name_len-1] = '\0'; - } else { + } else if (out_tvb) { tvb_memcpy(out_tvb, name_string, 0, -1); name_string[tvb_length(out_tvb)] = '\0'; } -- cgit v1.2.3