From 1807d3874a4efc673fec89448209f426a0301f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Thu, 19 Aug 2021 08:19:24 +0200 Subject: [PATCH] coap: Do not handle Accept as Content-Format Only use value of Content-Format to dissect the content in the current packet. Accept is used to tell which format is expected in the reply. Fixes: #17536 --- epan/dissectors/packet-coap.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/epan/dissectors/packet-coap.c b/epan/dissectors/packet-coap.c index 8569b77a81..a8bc32660a 100644 --- a/epan/dissectors/packet-coap.c +++ b/epan/dissectors/packet-coap.c @@ -664,6 +664,24 @@ dissect_coap_opt_ctype(tvbuff_t *tvb, proto_item *head_item, proto_tree *subtree proto_item_append_text(head_item, ": %s", coinfo->ctype_str); } +static void +dissect_coap_opt_accept(tvbuff_t *tvb, proto_item *head_item, proto_tree *subtree, gint offset, gint opt_length, int hf) +{ + const guint8 *str = NULL; + + if (opt_length == 0) { + str = nullstr; + } else { + guint value = coap_get_opt_uint(tvb, offset, opt_length); + str = val_to_str(value, vals_ctype, "Unknown Type %u"); + } + + proto_tree_add_string(subtree, hf, tvb, offset, opt_length, str); + + /* add info to the head of the packet detail */ + proto_item_append_text(head_item, ": %s", str); +} + static void dissect_coap_opt_block(tvbuff_t *tvb, proto_item *head_item, proto_tree *subtree, gint offset, gint opt_length, coap_info *coinfo, coap_common_dissect_t *dissect_hf) { @@ -923,8 +941,8 @@ dissect_coap_options_main(tvbuff_t *tvb, packet_info *pinfo, proto_tree *coap_tr opt_length, dissect_hf->hf.opt_hop_limit); break; case COAP_OPT_ACCEPT: - dissect_coap_opt_ctype(tvb, item, subtree, offset, - opt_length, dissect_hf->hf.opt_accept, coinfo); + dissect_coap_opt_accept(tvb, item, subtree, offset, + opt_length, dissect_hf->hf.opt_accept); break; case COAP_OPT_IF_MATCH: dissect_coap_opt_hex_string(tvb, pinfo, item, subtree, offset,