[Patch] natString.cc: Some fixes for bounds checking arithmetic.

Ralph Loader suckfish@ihug.co.nz
Tue Sep 23 07:51:00 GMT 2003


libgcj contains many places where checking of array index arguments
passed to methods is done incorrectly.

The attached patch fixes those in natString.cc that it is not difficult
to write test cases for.

One of the test cases in the patch is commented out - it causes a
warning during the link, which seems to cause the test to fail
extraneously.  If someone can tell me how to turn off or ignore the
warning message, I will do so and uncomment the test case.

This patch passes a make check in libjava.

There are many other instances of incorrect bounds checking that would
require a 64 bit machine with gigabytes of memory (which I don't have),
in order to write proper test cases.

Alternatively, I could fix those without test cases.  Would that be
acceptable?

Ralph.

2003-09-23  Ralph Loader  <suckfish@ihug.co.nz>

	* java/lang/natString.cc (getChars):
	Fix validation of array indexes.
	(getBytes, regionMatches, startsWith, valueOf): Likewise.
	* testsuite/libjava.lang/String_overflow.java: New file.
 	* testsuite/libjava.lang/String_overflow.out: New file.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: string.diff
Type: text/x-patch
Size: 6271 bytes
Desc: 
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20030923/e1f87416/attachment.bin>


More information about the Java-patches mailing list