aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-ftp.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-10-19 23:14:50 -0700
committerGuy Harris <guy@alum.mit.edu>2014-10-20 06:15:19 +0000
commit80e6f6251e96dd7b8a9ab0fdbf63b03a73ef6692 (patch)
tree92d519b9b19cccba0d083a6ad20152352daa5924 /epan/dissectors/packet-ftp.c
parent0b9eb9f4b71b6632cfb4b87bcdefdfa75eaf2dd0 (diff)
Get rid of calls to ctype.h functions.
They don't handle values outside the range -1 to 127, and their behavior is locale-dependent. Use g_ascii_isXXX() and g_ascii_toXXX() instead of isXXX() and toXXX(). If you're checking for printable ASCII, don't use isascii() and don't use iscntrl(), use g_ascii_isprint(). If you're checking for graphical ASCII, i.e. printable ASCII except for a space, use g_ascii_isgraph(). Use ws_xton() to convert a hex digit character to the corresponding numeric value. Change-Id: Id3039bc586fbf66d8736c2df248c790c0d7a2330 Reviewed-on: https://code.wireshark.org/review/4851 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/dissectors/packet-ftp.c')
-rw-r--r--epan/dissectors/packet-ftp.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/epan/dissectors/packet-ftp.c b/epan/dissectors/packet-ftp.c
index 2557457dc0..b153ad7bf3 100644
--- a/epan/dissectors/packet-ftp.c
+++ b/epan/dissectors/packet-ftp.c
@@ -28,7 +28,6 @@
#include <stdio.h>
#include <stdlib.h>
-#include <ctype.h>
#include <string.h>
#include <glib.h>
@@ -218,7 +217,7 @@ parse_port_pasv(const guchar *line, int linelen, guint32 *ftp_ip, guint16 *ftp_p
/*
* Look for a digit.
*/
- while ((c = *p) != '\0' && !isdigit(c))
+ while ((c = *p) != '\0' && !g_ascii_isdigit(c))
p++;
if (*p == '\0') {
@@ -255,7 +254,7 @@ parse_port_pasv(const guchar *line, int linelen, guint32 *ftp_ip, guint16 *ftp_p
* Well, that didn't work. Skip the first number we found,
* and keep trying.
*/
- while ((c = *p) != '\0' && isdigit(c))
+ while ((c = *p) != '\0' && g_ascii_isdigit(c))
p++;
}
@@ -267,9 +266,9 @@ isvalid_rfc2428_delimiter(const guchar c)
{
/* RFC2428 sect. 2 states rules for a valid delimiter */
const gchar *forbidden = "0123456789abcdef.:";
- if (c < 33 || c > 126)
+ if (!g_ascii_isgraph(c))
return FALSE;
- if (strchr(forbidden, tolower(c)))
+ if (strchr(forbidden, g_ascii_tolower(c)))
return FALSE;
return TRUE;
}
@@ -629,8 +628,8 @@ dissect_ftp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* treat non-continuation lines not beginning with digits
* as errors?
*/
- if (linelen >= 3 && isdigit(line[0]) && isdigit(line[1])
- && isdigit(line[2])) {
+ if (linelen >= 3 && g_ascii_isdigit(line[0]) && g_ascii_isdigit(line[1])
+ && g_ascii_isdigit(line[2])) {
/*
* One-line reply, or first or last line
* of a multi-line reply.