This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
RE: avoid compiler warning in regex matcher
- From: "Howland Craig D (Craig)" <howland at LGSInnovations dot com>
- To: <newlib at sourceware dot org>
- Cc: "Eric Blake" <eblake at redhat dot com>
- Date: Fri, 2 Mar 2012 21:05:31 -0500
- Subject: RE: avoid compiler warning in regex matcher
Eric Blake wrote:
> I'm not sure if this warning is the sign of a real exploitable bug,
but
> better safe than sorry:
> ...
> ../../../../../newlib/libc/posix/engine.c:184:5: warning: array
> subscript has type char
Eric:
The proposed cast to remove the warning will break things. See
line
1950 of regcomp.c, where the natural sign of char is taken into account
when generating the charjump table which is indexed by the "offending"
lines. Here are lines 1949-1950 of regcomp.c:
/* Adjust for signed chars, if necessary */
g->charjump = &g->charjump[-(CHAR_MIN)];
We either need to live with the warning, or else get rid of it a
different way. Something like this is somewhat crude, but would work.
+ #if CHAR_MIN!=0 /* If "plain" char is signed, declare dp as
explicitly s
igned to avoid GCC warning */
+ signed
+ #endif
char *dp;
(I didn't try it in the file to see if any other warnings arose or not.)
Craig