From 650c0f93be4765c8a2dc2db035fe1d0542a047c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Mon, 3 Oct 2016 21:09:28 +0200 Subject: [PATCH] p1: Check for valid tvb before tvb_reported_length MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the modification of the content item (which adds the length) inside the check for a valid tvb to avoid calling tvb_reported_length() with a NULL parameter. Bug: 12976 Change-Id: I54368584b7c00f7a2937eaec772533ae73d98f80 Reviewed-on: https://code.wireshark.org/review/18050 Petri-Dish: Stig Bjørlykke Reviewed-by: Pascal Quantin Reviewed-by: Stig Bjørlykke --- epan/dissectors/asn1/p1/p1.cnf | 2 +- epan/dissectors/packet-p1.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/epan/dissectors/asn1/p1/p1.cnf b/epan/dissectors/asn1/p1/p1.cnf index f077216af1..06b8d1a86c 100644 --- a/epan/dissectors/asn1/p1/p1.cnf +++ b/epan/dissectors/asn1/p1/p1.cnf @@ -679,9 +679,9 @@ MessageToken B "2.6.1.7.36" "id-hat-forwarded-token" /* we can do this now constructed octet strings are supported */ offset = dissect_ber_octet_string(FALSE, actx, tree, tvb, offset, hf_index, &next_tvb); - proto_item_set_text(actx->created_item, "content (%%u bytes)", tvb_reported_length (next_tvb)); if (next_tvb) { + proto_item_set_text(actx->created_item, "content (%%u bytes)", tvb_reported_length (next_tvb)); if (ctx && ctx->content_type_id) { (void) call_ber_oid_callback(ctx->content_type_id, next_tvb, 0, actx->pinfo, actx->subtree.top_tree ? actx->subtree.top_tree : tree, actx->private_data); } else if (ctx && ctx->report_unknown_content_type) { diff --git a/epan/dissectors/packet-p1.c b/epan/dissectors/packet-p1.c index bbfa1fc728..be5ccc5dfd 100644 --- a/epan/dissectors/packet-p1.c +++ b/epan/dissectors/packet-p1.c @@ -3248,9 +3248,9 @@ dissect_p1_Content(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, /* we can do this now constructed octet strings are supported */ offset = dissect_ber_octet_string(FALSE, actx, tree, tvb, offset, hf_index, &next_tvb); - proto_item_set_text(actx->created_item, "content (%u bytes)", tvb_reported_length (next_tvb)); if (next_tvb) { + proto_item_set_text(actx->created_item, "content (%u bytes)", tvb_reported_length (next_tvb)); if (ctx && ctx->content_type_id) { (void) call_ber_oid_callback(ctx->content_type_id, next_tvb, 0, actx->pinfo, actx->subtree.top_tree ? actx->subtree.top_tree : tree, actx->private_data); } else if (ctx && ctx->report_unknown_content_type) {