This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]