aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.c
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2022-02-03 08:28:11 -0500
committerA Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2022-02-06 00:32:13 +0000
commit25d0c88251b7649cd58ae791252ec74d6ab6e3de (patch)
tree18319432dcff185e9ce8325336267799067276c5 /epan/tvbuff.c
parentebe22f7b7b6238d2cbe35889c89ffc3c485ea696 (diff)
epan: Add BASE_SHOW_UTF_8_PRINTABLE
Add BASE_SHOW_UTF_8_PRINTABLE and related function tvb_utf_8_isprint for supporting fields of bytes that are "maybe UTF-8" (default or SHOULD be UTF-8 but could be something else, with no encoding indicator), such as SSID fields in IEEE 802.11 (See #16208), certain OctetString fields in Diameter or PFCP, and other places where BASE_SHOW_ASCII_PRINTABLE is currently used. Fix #5307
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r--epan/tvbuff.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index 7c7bc4c21e..a93bc5258c 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -3884,6 +3884,18 @@ gboolean tvb_ascii_isprint(tvbuff_t *tvb, const gint offset, const gint length)
return TRUE;
}
+gboolean tvb_utf_8_isprint(tvbuff_t *tvb, const gint offset, const gint length)
+{
+ const guint8* buf = tvb_get_ptr(tvb, offset, length);
+ guint abs_offset, abs_length = length;
+
+ if (length == -1) {
+ /* tvb_get_ptr has already checked for exceptions. */
+ compute_offset_and_remaining(tvb, offset, &abs_offset, &abs_length);
+ }
+
+ return isprint_utf8_string(buf, abs_length);
+}
static ws_mempbrk_pattern pbrk_crlf;
/*