From 78f28015918dcce627f2b22964615aa9e6a36ee3 Mon Sep 17 00:00:00 2001 From: stig Date: Fri, 23 Nov 2007 12:22:22 +0000 Subject: Moved check for empty choice to make it work correctly. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@23548 f5534014-38df-0310-8fa8-9805f1628bb7 --- epan/dissectors/packet-ber.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'epan/dissectors/packet-ber.c') diff --git a/epan/dissectors/packet-ber.c b/epan/dissectors/packet-ber.c index cb68106b60..120534cabd 100644 --- a/epan/dissectors/packet-ber.c +++ b/epan/dissectors/packet-ber.c @@ -2560,6 +2560,13 @@ printf("CHOICE dissect_ber_choice(%s) entered len:%d\n",name,tvb_length_remainin #endif start_offset=offset; + if(tvb_length_remaining(tvb,offset) == 0) { + item = proto_tree_add_text(parent_tree, tvb, offset, 0, "BER Error: Empty choice was found"); + proto_item_set_expert_flags(item, PI_MALFORMED, PI_WARN); + expert_add_info_format(actx->pinfo, item, PI_MALFORMED, PI_WARN, "BER Error: Empty choice was found"); + return offset; + } + /* read header and len for choice field */ offset=get_ber_identifier(tvb, offset, &class, &pc, &tag); offset=get_ber_length(tvb, offset, &len, &ind); @@ -2637,13 +2644,6 @@ printf("CHOICE testing potential subdissector class[%p]:%d:(expected)%d tag:%d: } } - if(length == 0) { - item = proto_tree_add_text(tree, tvb, hoffset, 0, "BER Error: Empty choice field was found"); - proto_item_set_expert_flags(item, PI_MALFORMED, PI_WARN); - expert_add_info_format(actx->pinfo, item, PI_MALFORMED, PI_WARN, "BER Error: Empty choice field was found"); - return hoffset; - } - length_remaining=tvb_length_remaining(tvb, hoffset); if(length_remaining>length) length_remaining=length; @@ -2794,6 +2794,13 @@ printf("CHOICE dissect_ber_old_choice(%s) entered len:%d\n",name,tvb_length_rema #endif start_offset=offset; + if(tvb_length_remaining(tvb,offset) == 0) { + item = proto_tree_add_text(parent_tree, tvb, offset, 0, "BER Error: Empty choice was found"); + proto_item_set_expert_flags(item, PI_MALFORMED, PI_WARN); + expert_add_info_format(actx->pinfo, item, PI_MALFORMED, PI_WARN, "BER Error: Empty choice was found"); + return offset; + } + /* read header and len for choice field */ offset=get_ber_identifier(tvb, offset, &class, &pc, &tag); offset=get_ber_length(tvb, offset, &len, &ind); @@ -2871,13 +2878,6 @@ printf("CHOICE testing potential subdissector class[%p]:%d:(expected)%d tag:%d: } } - if(length == 0) { - item = proto_tree_add_text(tree, tvb, hoffset, 0, "BER Error: Empty choice field was found"); - proto_item_set_expert_flags(item, PI_MALFORMED, PI_WARN); - expert_add_info_format(actx->pinfo, item, PI_MALFORMED, PI_WARN, "BER Error: Empty choice field was found"); - return hoffset; - } - length_remaining=tvb_length_remaining(tvb, hoffset); if(length_remaining>length) length_remaining=length; -- cgit v1.2.3