Module Name: src
Committed By: christos
Date: Sat Sep 12 19:08:47 UTC 2015
Modified Files:
src/lib/libc/regex: regcomp.c
Log Message:
use the unsigned char version of the input char in all cases "cap[uc]" to
avoid accessing cap[negative], found by Elliott Hughes
To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/lib/libc/regex/regcomp.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/regex/regcomp.c
diff -u src/lib/libc/regex/regcomp.c:1.35 src/lib/libc/regex/regcomp.c:1.36
--- src/lib/libc/regex/regcomp.c:1.35 Tue Feb 17 15:30:44 2015
+++ src/lib/libc/regex/regcomp.c Sat Sep 12 15:08:47 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: regcomp.c,v 1.35 2015/02/17 20:30:44 joerg Exp $ */
+/* $NetBSD: regcomp.c,v 1.36 2015/09/12 19:08:47 christos Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -76,7 +76,7 @@
#if 0
static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94";
#else
-__RCSID("$NetBSD: regcomp.c,v 1.35 2015/02/17 20:30:44 joerg Exp $");
+__RCSID("$NetBSD: regcomp.c,v 1.36 2015/09/12 19:08:47 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -1074,19 +1074,19 @@ ordinary(
int ch)
{
cat_t *cap;
+ unsigned char uc = (unsigned char)ch;
_DIAGASSERT(p != NULL);
cap = p->g->categories;
- if ((p->g->cflags®_ICASE) && isalpha((unsigned char) ch)
- && othercase((unsigned char) ch) != (unsigned char) ch)
- bothcases(p, (unsigned char) ch);
+ if ((p->g->cflags & REG_ICASE) && isalpha(uc) && othercase(uc) != uc)
+ bothcases(p, uc);
else {
- EMIT(OCHAR, (sopno)(unsigned char)ch);
- if (cap[ch] == 0) {
+ EMIT(OCHAR, (sopno)uc);
+ if (cap[uc] == 0) {
_DIAGASSERT(__type_fit(unsigned char,
p->g->ncategories + 1));
- cap[ch] = (unsigned char)p->g->ncategories++;
+ cap[uc] = (unsigned char)p->g->ncategories++;
}
}
}