diff options
author | Roman-Koshelev <roman.koshelev@bk.ru> | 2021-04-01 18:00:25 +0300 |
---|---|---|
committer | Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org> | 2021-04-02 06:31:45 +0000 |
commit | b13065cdc08898298cb05a4aa5f297a81438c83a (patch) | |
tree | d005ba6a52ab2959b97f5042a8a27c70a5e8686f | |
parent | 255fafad70dbc414ab3234a860c2e243d2bf804d (diff) |
TFTP: Fix is_valid_requerest_body
-rw-r--r-- | epan/dissectors/packet-tftp.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/epan/dissectors/packet-tftp.c b/epan/dissectors/packet-tftp.c index e2b9d486bd..8191f0cd8f 100644 --- a/epan/dissectors/packet-tftp.c +++ b/epan/dissectors/packet-tftp.c @@ -762,12 +762,19 @@ static gboolean is_valid_requerest_body(tvbuff_t *tvb) { gint offset = 2; + guint zeros_counter = 0; for (gint i = offset; i < (gint)tvb_captured_length(tvb); ++i) { gchar c = (gchar)tvb_get_guint8(tvb, i); - gboolean allowed_ch = (c == '\0') || g_ascii_isprint(c); - if (!allowed_ch) return FALSE; + if (c == '\0') { + zeros_counter++; + } else if (!g_ascii_isprint(c)) { + return FALSE; + } } + if (zeros_counter % 2 != 0 || zeros_counter == 0) + return FALSE; + offset += tvb_strsize(tvb, offset); guint len = tvb_strsize(tvb, offset); const gchar* mode = tvb_format_stringzpad(tvb, offset, len); |