avoid compiler warning in regex matcher
Howland Craig D (Craig)
howland@LGSInnovations.com
Sun Mar 4 05:29:00 GMT 2012
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
More information about the Newlib
mailing list