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]

avoid compiler warning in regex matcher


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: In function smatcher:
../../../../../newlib/libc/posix/engine.c:184:5: warning: array
subscript has type char
../../../../../newlib/libc/posix/engine.c:185:6: warning: array
subscript has type char
../../../../../newlib/libc/posix/engine.c:201:5: warning: array
subscript has type char

OK to apply?


2012-02-27  Eric Blake  <eblake@redhat.com>

	* libc/posix/engine.c (matcher): Avoid negative index.

Index: libc/posix/engine.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/posix/engine.c,v
retrieving revision 1.1
diff -u -p -r1.1 engine.c
--- libc/posix/engine.c	31 Oct 2008 21:03:41 -0000	1.1
+++ libc/posix/engine.c	28 Feb 2012 00:15:18 -0000
@@ -181,8 +181,8 @@ int eflags;
 			pp = mustlast;
 			for (dp = start+g->mlen-1; dp < stop;) {
 				/* Fast skip non-matches */
-				while (dp < stop && charjump[*dp])
-					dp += charjump[*dp];
+				while (dp < stop && charjump[(unsigned char)*dp])
+					dp += charjump[(unsigned char)*dp];

 				if (dp >= stop)
 					break;
@@ -198,7 +198,7 @@ int eflags;

 				/* Jump to next possible match */
 				mj = matchjump[pp - mustfirst];
-				cj = charjump[*dp];
+				cj = charjump[(unsigned char)*dp];
 				dp += (cj < mj ? mj : cj);
 				pp = mustlast;
 			}


-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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