aboutsummaryrefslogtreecommitdiffstats
path: root/epan/ftypes
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-10-16 12:05:26 -0700
committerGuy Harris <guy@alum.mit.edu>2014-10-16 19:08:19 +0000
commitf6bc6f957a13471fecb4ce0a31ca09f30cdde44f (patch)
tree099015e49e61ce69f757bf178c742aa9ea871120 /epan/ftypes
parent7f7447122999a8c20655651bcc8a5c1da0d49da7 (diff)
Better fix - just check that the upper and lower nibbles are >= 0xA.
An unsigned 8-bit integer is always <= 0xFF; that was the cause of the warning. To see whether a byte, when represented as hex, has letters for its upper and lower nibbles, just check whether both nibbles are >= 0xA. Cast the extracted nibbles to make sure there's no sign-extension. Change-Id: If4c7717a5d2fe341c02e9309ee6b89973a6ac292 Reviewed-on: https://code.wireshark.org/review/4739 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/ftypes')
-rw-r--r--epan/ftypes/ftype-pcre.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/epan/ftypes/ftype-pcre.c b/epan/ftypes/ftype-pcre.c
index 693ea88423..947aff3047 100644
--- a/epan/ftypes/ftype-pcre.c
+++ b/epan/ftypes/ftype-pcre.c
@@ -50,27 +50,15 @@ static gboolean
raw_flag_needed(const gchar *pattern)
{
gboolean found = FALSE;
- /*
- * 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;
+ const gchar *s = pattern;
size_t i, len;
/* find any character whose hex value is two letters */
- len = strlen(pattern);
- s = (const guint8 *)pattern;
+ len = strlen(s);
for (i = 0; i < len; i++) {
- 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))
+ /* Upper and lower-nibble must be >= 0xA */
+ if ((guchar)(s[i] & 0xF0) >= 0xA0 &&
+ (guchar)(s[i] & 0x0F) >= 0x0A)
{
found = TRUE;
break;