aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.h
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2022-10-14 20:36:51 -0400
committerJohn Thacker <johnthacker@gmail.com>2022-10-16 22:43:39 +0000
commit5fd09b521dbca9beaad7b5407e2df511a6ff413f (patch)
tree84d664d4f802a2e842db526e9f93a535c75810e6 /epan/tvbuff.h
parent94b4202a99d41404b09bc85fa91e226408f3389f (diff)
ftp: deal with UTF-8
Ensure that FTP doesn't add invalid strings to the tree or columns. Also allow UTF-8 pathnames to work. According to RFC 2640, FTP supports UTF-8 for pathnames (and it MUST be supported even if the other side does not advertise support for UTF-8, unless a different character set has been explicitly configured, which is out of scope of the RFCs, and we don't have such a preference.) So in general interpret strings as UTF-8, not ASCII. Reduce the use of tvb_get_ptr by using functions directly on the original tvb and offset. This also happens to be more compliant with RFC 2640 when getting the token lengths. (RFC 2640 states that implementations MUST assume that there is only one space between a command and the pathname, and treat additional spaces as part of the pathname instead of skipping them. tvb_get_token_len() does not skip trailing spaces, but get_token_len() does.) The only place that still uses tvb_get_ptr is when processing a PWD command, because it has to deal with the double quote escaping as a custom encoding. Add a tvb_ascii_isdigit function. Fix #18439.
Diffstat (limited to 'epan/tvbuff.h')
-rw-r--r--epan/tvbuff.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/epan/tvbuff.h b/epan/tvbuff.h
index dbc2e4c96f..dfd57adaaa 100644
--- a/epan/tvbuff.h
+++ b/epan/tvbuff.h
@@ -835,6 +835,13 @@ WS_DLL_PUBLIC gboolean tvb_ascii_isprint(tvbuff_t *tvb, const gint offset,
WS_DLL_PUBLIC gboolean tvb_utf_8_isprint(tvbuff_t *tvb, const gint offset,
const gint length);
+/** Iterates over the provided portion of the tvb checking that each byte
+* is an ascii digit.
+* Returns TRUE if all bytes are digits, FALSE otherwise
+*/
+WS_DLL_PUBLIC gboolean tvb_ascii_isdigit(tvbuff_t *tvb, const gint offset,
+ const gint length);
+
/**
* Given a tvbuff, an offset into the tvbuff, and a length that starts
* at that offset (which may be -1 for "all the way to the end of the