aboutsummaryrefslogtreecommitdiffstats
path: root/sharkd_session.c
diff options
context:
space:
mode:
authorZach Chadwick <zachad@qacafe.com>2023-02-08 17:45:32 -0500
committerGerald Combs <gerald@wireshark.org>2023-02-13 19:49:16 +0000
commit583c8492e5a16c03df2656084121dcab6dd5c295 (patch)
tree18ba6a7f153eb780e8712a9a9ab928ffb6eb1428 /sharkd_session.c
parentbd24f450f81e811948cbad9ffc32fd4734460d72 (diff)
Zero-pad any RGB color used for a bg or fg
The `color_t_to_rgb` method returns an unsigned int, taking a 32-bit color code and reducing it to an integer. Sharkd displays these as hex colors. However, if this color is missing a Red or Green component, the hex output is missing the zero-padding for those parts of the color, resulting in the wrong or invalid hex code. This patch simply pads the output with zeros.
Diffstat (limited to 'sharkd_session.c')
-rw-r--r--sharkd_session.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sharkd_session.c b/sharkd_session.c
index 2222b8950d..d1f8496d8b 100644
--- a/sharkd_session.c
+++ b/sharkd_session.c
@@ -1359,8 +1359,8 @@ sharkd_session_process_frames_cb(epan_dissect_t *edt, proto_tree *tree _U_,
if (fdata->color_filter)
{
- sharkd_json_value_stringf("bg", "%x", color_t_to_rgb(&fdata->color_filter->bg_color));
- sharkd_json_value_stringf("fg", "%x", color_t_to_rgb(&fdata->color_filter->fg_color));
+ sharkd_json_value_stringf("bg", "%06x", color_t_to_rgb(&fdata->color_filter->bg_color));
+ sharkd_json_value_stringf("fg", "%06x", color_t_to_rgb(&fdata->color_filter->fg_color));
}
json_dumper_end_object(&dumper);
@@ -3491,8 +3491,8 @@ sharkd_session_process_frame_cb(epan_dissect_t *edt, proto_tree *tree, struct ep
if (fdata->color_filter)
{
- sharkd_json_value_stringf("bg", "%x", color_t_to_rgb(&fdata->color_filter->bg_color));
- sharkd_json_value_stringf("fg", "%x", color_t_to_rgb(&fdata->color_filter->fg_color));
+ sharkd_json_value_stringf("bg", "%06x", color_t_to_rgb(&fdata->color_filter->bg_color));
+ sharkd_json_value_stringf("fg", "%06x", color_t_to_rgb(&fdata->color_filter->fg_color));
}
if (data_src)