jni.cc (_Jv_JNI_GetPrimitiveArrayRegion): Fixed bounds checking.

* jni.cc (_Jv_JNI_GetPrimitiveArrayRegion): Fixed bounds
	checking.
	(_Jv_JNI_SetPrimitiveArrayRegion): Likewise.

From-SVN: r41634
This commit is contained in:
Tom Tromey 2001-04-27 16:09:54 +00:00
parent 09efa46f6a
commit 55cc31c086
2 changed files with 17 additions and 5 deletions

View File

@ -1,10 +1,16 @@
2001-04-27 Tom Tromey <tromey@redhat.com>
* jni.cc (_Jv_JNI_GetPrimitiveArrayRegion): Fixed bounds
checking.
(_Jv_JNI_SetPrimitiveArrayRegion): Likewise.
2001-04-27 Martin Kahlert <martin.kahlert@infineon.com> 2001-04-27 Martin Kahlert <martin.kahlert@infineon.com>
* include/jni.h (struct JNINativeInterface): Fixed types in * include/jni.h (struct JNINativeInterface): Fixed types in
Get/Set*ArrayRegion declarations. Get/Set*ArrayRegion declarations.
(class _Jv_JNIEnv): Likewise. (class _Jv_JNIEnv): Likewise.
2001-04-25 Bryce McKinlay <bryce@albatross.co.nz> 2001-04-26 Alexandre Oliva <aoliva@redhat.com>
* configure.in: Obtain THREADS with `gcc -v'. * configure.in: Obtain THREADS with `gcc -v'.
* configure: Rebuilt. * configure: Rebuilt.

View File

@ -1364,7 +1364,9 @@ _Jv_JNI_GetPrimitiveArrayRegion (JNIEnv *env, JArray<T> *array,
jsize start, jsize len, jsize start, jsize len,
T *buf) T *buf)
{ {
if (start < 0 || len >= array->length || start + len >= array->length) // The cast to unsigned lets us save a comparison.
if (start < 0 || len < 0
|| (unsigned long) (start + len) >= (unsigned long) array->length)
{ {
try try
{ {
@ -1389,7 +1391,9 @@ static void
_Jv_JNI_SetPrimitiveArrayRegion (JNIEnv *env, JArray<T> *array, _Jv_JNI_SetPrimitiveArrayRegion (JNIEnv *env, JArray<T> *array,
jsize start, jsize len, T *buf) jsize start, jsize len, T *buf)
{ {
if (start < 0 || len >= array->length || start + len >= array->length) // The cast to unsigned lets us save a comparison.
if (start < 0 || len < 0
|| (unsigned long) (start + len) >= (unsigned long) array->length)
{ {
try try
{ {
@ -1432,7 +1436,8 @@ _Jv_JNI_MonitorEnter (JNIEnv *env, jobject obj)
{ {
try try
{ {
return _Jv_MonitorEnter (obj); _Jv_MonitorEnter (obj);
return 0;
} }
catch (jthrowable t) catch (jthrowable t)
{ {
@ -1446,7 +1451,8 @@ _Jv_JNI_MonitorExit (JNIEnv *env, jobject obj)
{ {
try try
{ {
return _Jv_MonitorExit (obj); _Jv_MonitorExit (obj);
return 0;
} }
catch (jthrowable t) catch (jthrowable t)
{ {