diff options
Diffstat (limited to 'epan/ftypes/ftype-pcre.c')
-rw-r--r-- | epan/ftypes/ftype-pcre.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/epan/ftypes/ftype-pcre.c b/epan/ftypes/ftype-pcre.c index e9e42681d6..693ea88423 100644 --- a/epan/ftypes/ftype-pcre.c +++ b/epan/ftypes/ftype-pcre.c @@ -50,18 +50,27 @@ static gboolean raw_flag_needed(const gchar *pattern) { gboolean found = FALSE; - const gchar *s = pattern; + /* + * gchar is neither guaranteed to be signed nor guaranteed to be + * unsigned. Make s point to guint8, and use regular hex constants, + * to make sure the comparisons are unsigned vs. unsigned (on at + * least one ARM version of gcc, with char being unsigned, the + * comparisons before those changes warned about always being + * true due to the limited range of the data type). + */ + const guint8 *s; size_t i, len; /* find any character whose hex value is two letters */ - len = strlen(s); + len = strlen(pattern); + s = (const guint8 *)pattern; for (i = 0; i < len; i++) { - if ((s[i] >= '\xAA' && s[i] <= '\xAF') || - (s[i] >= '\xBA' && s[i] <= '\xBF') || - (s[i] >= '\xCA' && s[i] <= '\xCF') || - (s[i] >= '\xDA' && s[i] <= '\xDF') || - (s[i] >= '\xEA' && s[i] <= '\xEF') || - (s[i] >= '\xFA' && s[i] <= '\xFF')) + if ((s[i] >= 0xAA && s[i] <= 0xAF) || + (s[i] >= 0xBA && s[i] <= 0xBF) || + (s[i] >= 0xCA && s[i] <= 0xCF) || + (s[i] >= 0xDA && s[i] <= 0xDF) || + (s[i] >= 0xEA && s[i] <= 0xEF) || + (s[i] >= 0xFA && s[i] <= 0xFF)) { found = TRUE; break; |