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
This commit is contained in:
parent
0e3dd56798
commit
b11f64301a
5 changed files with 203 additions and 170 deletions
|
@ -328,7 +328,8 @@ java::lang::String::init(jcharArray chars, jint offset, jint count,
|
|||
if (! chars)
|
||||
JvThrow (new NullPointerException);
|
||||
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());
|
||||
jcharArray array;
|
||||
jchar *pdst;
|
||||
|
@ -451,7 +452,7 @@ java::lang::String::getChars(jint srcBegin, jint srcEnd,
|
|||
jint dst_length = JvGetArrayLength (dst);
|
||||
if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > count
|
||||
|| 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 *sPtr = JvGetStringChars (this) + srcBegin;
|
||||
register jint i = srcEnd-srcBegin;
|
||||
|
@ -501,7 +502,7 @@ java::lang::String::getBytes(jint srcBegin, jint srcEnd,
|
|||
jint dst_length = JvGetArrayLength (dst);
|
||||
if (srcBegin < 0 || srcBegin > srcEnd || srcEnd > count
|
||||
|| dstBegin < 0 || dstBegin + (srcEnd-srcBegin) > dst_length)
|
||||
JvThrow (new java::lang::ArrayIndexOutOfBoundsException());
|
||||
JvThrow (new java::lang::StringIndexOutOfBoundsException());
|
||||
register jbyte *dPtr = elements (dst) + dstBegin;
|
||||
register jchar *sPtr = JvGetStringChars (this) + srcBegin;
|
||||
register jint i = srcEnd-srcBegin;
|
||||
|
@ -591,19 +592,25 @@ java::lang::String::regionMatches (jboolean ignoreCase, jint toffset,
|
|||
register jchar *tptr = JvGetStringChars (this) + toffset;
|
||||
register jchar *optr = JvGetStringChars (other) + ooffset;
|
||||
register jint i = len;
|
||||
while (--i >= 0)
|
||||
{
|
||||
jchar tch = *tptr++;
|
||||
jchar och = *optr++;
|
||||
if (tch != och)
|
||||
return false;
|
||||
if (ignoreCase
|
||||
&& (java::lang::Character::toLowerCase (tch)
|
||||
!= java::lang::Character::toLowerCase (och))
|
||||
&& (java::lang::Character::toUpperCase (tch)
|
||||
!= java::lang::Character::toUpperCase (och)))
|
||||
return false;
|
||||
}
|
||||
if (ignoreCase)
|
||||
while (--i >= 0)
|
||||
{
|
||||
jchar tch = *tptr++;
|
||||
jchar och = *optr++;
|
||||
if ((java::lang::Character::toLowerCase (tch)
|
||||
!= java::lang::Character::toLowerCase (och))
|
||||
&& (java::lang::Character::toUpperCase (tch)
|
||||
!= java::lang::Character::toUpperCase (och)))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
while (--i >= 0)
|
||||
{
|
||||
jchar tch = *tptr++;
|
||||
jchar och = *optr++;
|
||||
if (tch != och)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue