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.
This commit is contained in:
John Thacker 2022-02-03 08:53:58 -05:00 committed by A Wireshark GitLab Utility
parent 3466798ed0
commit f2dbaa1d53
1 changed files with 6 additions and 1 deletions

View File

@ -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;