aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-coap.c
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2022-04-01 12:42:58 +0200
committerStig Bjørlykke <stig@bjorlykke.org>2022-04-01 12:42:58 +0200
commite6202cf1d9d9e176af8f81cf5898e0df1823ca9a (patch)
treeb9730f02a3bb5faa1c776d7df746f1a3ec79f867 /epan/dissectors/packet-coap.c
parentf23a774819bbea2b2ba2b17ad099463764762844 (diff)
coap: Format text used in COL_INFO
Use format_text_wsp() on strings from packet used in COL_INFO to show non-printable characters as C-style escapes.
Diffstat (limited to 'epan/dissectors/packet-coap.c')
-rw-r--r--epan/dissectors/packet-coap.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/epan/dissectors/packet-coap.c b/epan/dissectors/packet-coap.c
index 93f8160719..faf9fec752 100644
--- a/epan/dissectors/packet-coap.c
+++ b/epan/dissectors/packet-coap.c
@@ -30,6 +30,7 @@
#include <epan/expert.h>
#include <epan/wmem_scopes.h>
#include <epan/to_str.h>
+#include <epan/strutil.h>
#include "packet-dtls.h"
#include "packet-coap.h"
#include "packet-http.h"
@@ -458,7 +459,7 @@ dissect_coap_opt_uri_host(tvbuff_t *tvb, packet_info *pinfo, proto_item *head_it
proto_tree_add_item_ret_string(subtree, hf, tvb, offset, opt_length, ENC_ASCII, pinfo->pool, &str);
/* add info to the head of the packet detail */
- proto_item_append_text(head_item, ": %s", str);
+ proto_item_append_text(head_item, ": %s", format_text_wsp(pinfo->pool, str, strlen(str)));
/* forming a uri-string
* If the 'uri host' looks an IPv6 address, assuming that the address has
@@ -488,7 +489,7 @@ dissect_coap_opt_uri_path(tvbuff_t *tvb, packet_info *pinfo, proto_item *head_it
proto_tree_add_item(subtree, hf, tvb, offset, opt_length, ENC_ASCII);
/* add info to the head of the packet detail */
- proto_item_append_text(head_item, ": %s", str);
+ proto_item_append_text(head_item, ": %s", format_text_wsp(pinfo->pool, str, strlen(str)));
}
static void
@@ -509,7 +510,7 @@ dissect_coap_opt_uri_query(tvbuff_t *tvb, packet_info *pinfo, proto_item *head_i
proto_tree_add_item(subtree, hf, tvb, offset, opt_length, ENC_ASCII);
/* add info to the head of the packet detail */
- proto_item_append_text(head_item, ": %s", str);
+ proto_item_append_text(head_item, ": %s", format_text_wsp(pinfo->pool, str, strlen(str)));
}
static void
@@ -526,7 +527,7 @@ dissect_coap_opt_location_path(tvbuff_t *tvb, packet_info *pinfo, proto_item *he
proto_tree_add_item(subtree, hf, tvb, offset, opt_length, ENC_ASCII);
/* add info to the head of the packet detail */
- proto_item_append_text(head_item, ": %s", str);
+ proto_item_append_text(head_item, ": %s", format_text_wsp(pinfo->pool, str, strlen(str)));
}
static void
@@ -543,7 +544,7 @@ dissect_coap_opt_location_query(tvbuff_t *tvb, packet_info *pinfo, proto_item *h
proto_tree_add_item(subtree, hf, tvb, offset, opt_length, ENC_ASCII);
/* add info to the head of the packet detail */
- proto_item_append_text(head_item, ": %s", str);
+ proto_item_append_text(head_item, ": %s", format_text_wsp(pinfo->pool, str, strlen(str)));
}
/* rfc8613 */
@@ -658,7 +659,7 @@ dissect_coap_opt_proxy_uri(tvbuff_t *tvb, packet_info *pinfo, proto_item *head_i
proto_tree_add_item(subtree, hf, tvb, offset, opt_length, ENC_ASCII);
/* add info to the head of the packet detail */
- proto_item_append_text(head_item, ": %s", str);
+ proto_item_append_text(head_item, ": %s", format_text_wsp(pinfo->pool, str, strlen(str)));
}
static void
@@ -675,7 +676,7 @@ dissect_coap_opt_proxy_scheme(tvbuff_t *tvb, packet_info *pinfo, proto_item *hea
proto_tree_add_item(subtree, hf, tvb, offset, opt_length, ENC_ASCII);
/* add info to the head of the packet detail */
- proto_item_append_text(head_item, ": %s", str);
+ proto_item_append_text(head_item, ": %s", format_text_wsp(pinfo->pool, str, strlen(str)));
}
static void
@@ -1432,13 +1433,13 @@ dissect_coap_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree,
(coinfo->block_mflag || !mflag_is_used) ? "" : "End of ", coinfo->block_number);
}
if (wmem_strbuf_get_len(coinfo->uri_str_strbuf) > 0) {
- col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", wmem_strbuf_get_str(coinfo->uri_str_strbuf));
+ col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", format_text_wsp(pinfo->pool, wmem_strbuf_get_str(coinfo->uri_str_strbuf), wmem_strbuf_get_len(coinfo->uri_str_strbuf)));
/* Add a generated protocol item as well */
pi = proto_tree_add_string(coap_tree, dissect_coap_hf.hf.opt_uri_path_recon, tvb, 0, 0, wmem_strbuf_get_str(coinfo->uri_str_strbuf));
proto_item_set_generated(pi);
}
if (wmem_strbuf_get_len(coinfo->uri_query_strbuf) > 0)
- col_append_str(pinfo->cinfo, COL_INFO, wmem_strbuf_get_str(coinfo->uri_query_strbuf));
+ col_append_str(pinfo->cinfo, COL_INFO, format_text_wsp(pinfo->pool, wmem_strbuf_get_str(coinfo->uri_query_strbuf), wmem_strbuf_get_len(coinfo->uri_query_strbuf)));
if (coap_req_rsp != NULL) {
/* Print state tracking in the tree */