aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.c
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2022-02-03 08:53:58 -0500
committerA Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2022-02-03 22:47:35 +0000
commitf2dbaa1d533ceb9a02cbb9fcfd79094c5af574e8 (patch)
tree535231424ee82b1b8c2af2d1d25dc65a269991c7 /epan/tvbuff.c
parent3466798ed01e3734d2f75ee981bd2808e7da1da6 (diff)
epan: Handle -1 length in tvb_ascii_isprint
tvb_ascii_isprint like other tvb_ functions accepts -1 as a parameter, meaning "to the end of the tvb". Get the real length for the loop.
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r--epan/tvbuff.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index 5dab307577..7c7bc4c21e 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -3871,8 +3871,13 @@ tvb_get_raw_bytes_as_string(tvbuff_t *tvb, const gint offset, char *buffer, size
gboolean tvb_ascii_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;
- for (int i = 0; i < length; i++, buf++)
+ if (length == -1) {
+ /* tvb_get_ptr has already checked for exceptions. */
+ compute_offset_and_remaining(tvb, offset, &abs_offset, &abs_length);
+ }
+ for (guint i = 0; i < abs_length; i++, buf++)
if (!g_ascii_isprint(*buf))
return FALSE;