aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2019-07-16 15:55:23 -0700
committerGuy Harris <guy@alum.mit.edu>2019-07-16 23:34:32 +0000
commitce1adf9862709c1b3d77b14bfac20626e5c5f723 (patch)
tree0b9e9a702ca77128d124b414f8a03d20903889e7
parentd699c5d84c498b4a853b64ff2826ff5504eaf096 (diff)
Don't just grab raw string data with tvb_memcpy().
Use proto_tree_add_item_ret_display_string() routines to add strings if we want to display the string's value in a column. That way, all strings are fetched using an encoding value, to properly map to UTF-8, and are formatted for display. Change-Id: I4acd9ed7cfad3342be84a4773187dd531949f47b Reviewed-on: https://code.wireshark.org/review/33974 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r--epan/dissectors/packet-distcc.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/epan/dissectors/packet-distcc.c b/epan/dissectors/packet-distcc.c
index a36502bed8..ac63708bba 100644
--- a/epan/dissectors/packet-distcc.c
+++ b/epan/dissectors/packet-distcc.c
@@ -112,9 +112,8 @@ dissect_distcc_argc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int off
static int
dissect_distcc_argv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint parameter)
{
- char argv[256];
- int argv_len;
gint len=(gint)parameter;
+ char *argv;
proto_item* ti;
CHECK_PDU_LEN("ARGV");
@@ -122,11 +121,12 @@ dissect_distcc_argv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int off
/* see if we need to desegment the PDU */
DESEGMENT_TCP("ARGV");
- argv_len=len>255?255:len;
- tvb_memcpy(tvb, argv, offset, argv_len);
- argv[argv_len]=0;
-
- ti = proto_tree_add_item(tree, hf_distcc_argv, tvb, offset, len, ENC_ASCII|ENC_NA);
+ /*
+ * XXX - we have no idea what encoding is being used, other than
+ * it being some flavor of "extended ASCII"; these days, it's
+ * *probably* UTF-8, but it could conceivably be something else.
+ */
+ ti = proto_tree_add_item_ret_display_string(tree, hf_distcc_argv, tvb, offset, len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &argv);
col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", argv);
@@ -139,9 +139,8 @@ dissect_distcc_argv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int off
static int
dissect_distcc_serr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint parameter)
{
- char argv[256];
- int argv_len;
gint len=(gint)parameter;
+ char *serr;
proto_item* ti;
CHECK_PDU_LEN("SERR");
@@ -149,13 +148,14 @@ dissect_distcc_serr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int off
/* see if we need to desegment the PDU */
DESEGMENT_TCP("SERR");
- argv_len=len>255?255:len;
- tvb_memcpy(tvb, argv, offset, argv_len);
- argv[argv_len]=0;
-
- ti = proto_tree_add_item(tree, hf_distcc_serr, tvb, offset, len, ENC_ASCII|ENC_NA);
+ /*
+ * XXX - we have no idea what encoding is being used, other than
+ * it being some flavor of "extended ASCII"; these days, it's
+ * *probably* UTF-8, but it could conceivably be something else.
+ */
+ ti = proto_tree_add_item_ret_display_string(tree, hf_distcc_serr, tvb, offset, len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &serr);
- col_append_fstr(pinfo->cinfo, COL_INFO, "SERR:%s ", argv);
+ col_append_fstr(pinfo->cinfo, COL_INFO, "SERR:%s ", serr);
if(len!=(gint)parameter){
expert_add_info_format(pinfo, ti, &ei_distcc_short_pdu, "[Short SERR PDU]");
@@ -166,9 +166,8 @@ dissect_distcc_serr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int off
static int
dissect_distcc_sout(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, guint parameter)
{
- char argv[256];
- int argv_len;
gint len=(gint)parameter;
+ char *sout;
proto_item* ti;
CHECK_PDU_LEN("SOUT");
@@ -176,13 +175,14 @@ dissect_distcc_sout(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int off
/* see if we need to desegment the PDU */
DESEGMENT_TCP("SOUT");
- argv_len=len>255?255:len;
- tvb_memcpy(tvb, argv, offset, argv_len);
- argv[argv_len]=0;
-
- ti = proto_tree_add_item(tree, hf_distcc_sout, tvb, offset, len, ENC_ASCII|ENC_NA);
+ /*
+ * XXX - we have no idea what encoding is being used, other than
+ * it being some flavor of "extended ASCII"; these days, it's
+ * *probably* UTF-8, but it could conceivably be something else.
+ */
+ ti = proto_tree_add_item_ret_display_string(tree, hf_distcc_sout, tvb, offset, len, ENC_ASCII|ENC_NA, wmem_packet_scope(), &sout);
- col_append_fstr(pinfo->cinfo, COL_INFO, "SOUT:%s ", argv);
+ col_append_fstr(pinfo->cinfo, COL_INFO, "SOUT:%s ", sout);
if(len!=(gint)parameter){
expert_add_info_format(pinfo, ti, &ei_distcc_short_pdu, "[Short SOUT PDU]");