⬢ DragonFlyBSD Kernel Audit
DF-5692 / fix.diff
← back to finding ↓ download raw
--- a/sys/libkern/fnmatch.c
+++ b/sys/libkern/fnmatch.c
@@ -163,7 +163,7 @@
 rangematch(const char *pattern, char test, int flags, char **newp)
 {
 	int negate, ok;
-	char c, c2;
+	unsigned char c, c2;
 
 	/*
 	 * A bracket expression starting with an unquoted circumflex
@@ -208,9 +208,9 @@
 			if (flags & FNM_CASEFOLD)
 				c2 = tolower((unsigned char)c2);
 
-			if (c <= test && test <= c2)
+			if (c <= (unsigned char)test && (unsigned char)test <= c2)
 				ok = 1;
-		} else if (c == test) {
+		} else if (c == (unsigned char)test) {
 			ok = 1;
 		}
 	} while ((c = *pattern++) != ']');