Commit b11f6430 by Anthony Green Committed by Anthony Green

natString.cc (init): Test for overflow condition during out of bounds check.

2000-01-09  Anthony Green  <green@cygnus.com>

	* java/lang/natString.cc (init): Test for overflow condition
	during out of bounds check.
	(getChars): Throw StringIndexOutOfBoundsException, not
	ArrayIndexOutOfBoundsException.
	(getBytes): Ditto.
	(regionMatches): Obey case option during string comparison.

	* configure.host (ligcj_interpreter): New variable.  Enable
	interpreter by default on IA-32.
	* configure.in:  Examine libgcj_interpreter.
	* configure: Rebuilt.

From-SVN: r31300
parent 0e3dd567
2000-01-09 Anthony Green <green@cygnus.com>
* java/lang/natString.cc (init): Test for overflow condition
during out of bounds check.
(getChars): Throw StringIndexOutOfBoundsException, not
ArrayIndexOutOfBoundsException.
(getBytes): Ditto.
(regionMatches): Obey case option during string comparison.
* configure.host (ligcj_interpreter): New variable. Enable
interpreter by default on IA-32.
* configure.in: Examine libgcj_interpreter.
* configure: Rebuilt.
2000-01-07 Tom Tromey <tromey@cygnus.com> 2000-01-07 Tom Tromey <tromey@cygnus.com>
* mauve-libgcj: Don't disable ClassTest. * mauve-libgcj: Don't disable ClassTest.
......
...@@ -24,6 +24,7 @@ libgcj_cflags= ...@@ -24,6 +24,7 @@ libgcj_cflags=
libgcj_cxxflags= libgcj_cxxflags=
libgcj_javaflags= libgcj_javaflags=
libgcj_sjlj= libgcj_sjlj=
libgcj_interpreter=
case "${target_optspace}:${host}" in case "${target_optspace}:${host}" in
yes:*) yes:*)
...@@ -58,6 +59,7 @@ case "${host}" in ...@@ -58,6 +59,7 @@ case "${host}" in
;; ;;
i686-*|i586-*) i686-*|i586-*)
libgcj_flags="${libgcj_flags} -ffloat-store" libgcj_flags="${libgcj_flags} -ffloat-store"
libgcj_interpreter=yes
DIVIDESPEC=-fno-use-divide-subroutine DIVIDESPEC=-fno-use-divide-subroutine
;; ;;
sparc-*) sparc-*)
......
...@@ -61,9 +61,14 @@ dnl See if the user has the interpreter included. ...@@ -61,9 +61,14 @@ dnl See if the user has the interpreter included.
AC_ARG_ENABLE(interpreter, AC_ARG_ENABLE(interpreter,
[ --enable-interpreter enable interpreter], [ --enable-interpreter enable interpreter],
if test "$enable_interpreter" = yes; then if test "$enable_interpreter" = yes; then
AC_DEFINE(INTERPRETER) # This can also be set in configure.host.
libgcj_interpreter=yes
fi) fi)
if test "$libgcj_interpreter" = yes; then
AC_DEFINE(INTERPRETER)
fi
EXCEPTIONSPEC= EXCEPTIONSPEC=
dnl See if we should use setjmp/longjmp exceptions dnl See if we should use setjmp/longjmp exceptions
AC_ARG_ENABLE(sjlj-exceptions, AC_ARG_ENABLE(sjlj-exceptions,
......
...@@ -328,7 +328,8 @@ java::lang::String::init(jcharArray chars, jint offset, jint count, ...@@ -328,7 +328,8 @@ java::lang::String::init(jcharArray chars, jint offset, jint count,
if (! chars) if (! chars)
JvThrow (new NullPointerException); JvThrow (new NullPointerException);
jsize data_size = JvGetArrayLength (chars); jsize data_size = JvGetArrayLength (chars);
if (offset < 0 || count < 0 || offset + count > data_size) if (offset < 0 || count < 0 || offset + count < 0
|| offset + count > data_size)
JvThrow (new StringIndexOutOfBoundsException()); JvThrow (new StringIndexOutOfBoundsException());
jcharArray array; jcharArray array;
jchar *pdst; jchar *pdst;
...@@ -451,7 +452,7 @@ java::lang::String::getChars(jint srcBegin, jint srcEnd, ...@@ -451,7 +452,7 @@ java::lang::String::getChars(jint srcBegin, jint srcEnd,
jint dst_length = JvGetArrayLength (dst); jint dst_length = JvGetArrayLength (dst);
if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > count if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > count
|| dstBegin < 0 || dstBegin + (srcEnd-srcBegin) > dst_length) || dstBegin < 0 || dstBegin + (srcEnd-srcBegin) > dst_length)
JvThrow (new java::lang::ArrayIndexOutOfBoundsException()); JvThrow (new java::lang::StringIndexOutOfBoundsException());
register jchar *dPtr = elements (dst) + dstBegin; register jchar *dPtr = elements (dst) + dstBegin;
register jchar *sPtr = JvGetStringChars (this) + srcBegin; register jchar *sPtr = JvGetStringChars (this) + srcBegin;
register jint i = srcEnd-srcBegin; register jint i = srcEnd-srcBegin;
...@@ -501,7 +502,7 @@ java::lang::String::getBytes(jint srcBegin, jint srcEnd, ...@@ -501,7 +502,7 @@ java::lang::String::getBytes(jint srcBegin, jint srcEnd,
jint dst_length = JvGetArrayLength (dst); jint dst_length = JvGetArrayLength (dst);
if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > count if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > count
|| dstBegin < 0 || dstBegin + (srcEnd-srcBegin) > dst_length) || dstBegin < 0 || dstBegin + (srcEnd-srcBegin) > dst_length)
JvThrow (new java::lang::ArrayIndexOutOfBoundsException()); JvThrow (new java::lang::StringIndexOutOfBoundsException());
register jbyte *dPtr = elements (dst) + dstBegin; register jbyte *dPtr = elements (dst) + dstBegin;
register jchar *sPtr = JvGetStringChars (this) + srcBegin; register jchar *sPtr = JvGetStringChars (this) + srcBegin;
register jint i = srcEnd-srcBegin; register jint i = srcEnd-srcBegin;
...@@ -591,19 +592,25 @@ java::lang::String::regionMatches (jboolean ignoreCase, jint toffset, ...@@ -591,19 +592,25 @@ java::lang::String::regionMatches (jboolean ignoreCase, jint toffset,
register jchar *tptr = JvGetStringChars (this) + toffset; register jchar *tptr = JvGetStringChars (this) + toffset;
register jchar *optr = JvGetStringChars (other) + ooffset; register jchar *optr = JvGetStringChars (other) + ooffset;
register jint i = len; register jint i = len;
while (--i >= 0) if (ignoreCase)
{ while (--i >= 0)
jchar tch = *tptr++; {
jchar och = *optr++; jchar tch = *tptr++;
if (tch != och) jchar och = *optr++;
return false; if ((java::lang::Character::toLowerCase (tch)
if (ignoreCase != java::lang::Character::toLowerCase (och))
&& (java::lang::Character::toLowerCase (tch) && (java::lang::Character::toUpperCase (tch)
!= java::lang::Character::toLowerCase (och)) != java::lang::Character::toUpperCase (och)))
&& (java::lang::Character::toUpperCase (tch) return false;
!= java::lang::Character::toUpperCase (och))) }
return false; else
} while (--i >= 0)
{
jchar tch = *tptr++;
jchar och = *optr++;
if (tch != och)
return false;
}
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment