This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Array index out of bound inside natClass.cc (+patch)
- To: java at gcc dot gnu dot org
- Subject: Array index out of bound inside natClass.cc (+patch)
- From: Martin Kahlert <martin dot kahlert at infineon dot com>
- Date: Mon, 21 May 2001 11:07:07 +0200
- Cc: java-patches at gcc dot gnu dot org
- Reply-To: martin dot kahlert at infineon dot com
Hi again!
While testing my application with Electric Fence i found
another error in libjava.
By printing the index in my application it found out, that it
sometimes was -4. Thus the first check.
The second one may be neccessary if target is a java.lang.Object (depth == 0)
and source->isPrimitive() == true (--> can this happen?).
Then source->ancestors[source->depth] would be out of bounds, too.
Bye,
Martin.
Here is my proposed patch:
2001-05-21 Martin Kahlert <martin.kahlert@infineon.com>
* java/lang/natClass.cc (_Jv_IsAssignableFrom): Ensure that array
index is within allowed bounds
diff -rc gcc-20010514.orig/libjava/java/lang/natClass.cc gcc-20010514/libjava/java/lang/natClass.cc
*** gcc-20010514.orig/libjava/java/lang/natClass.cc Sun May 6 16:08:26 2001
--- gcc-20010514/libjava/java/lang/natClass.cc Mon May 21 10:59:05 2001
***************
*** 947,952 ****
--- 947,953 ----
if ((target == &ObjectClass && !source->isPrimitive())
|| (source->ancestors != NULL
+ && source->depth >= target->depth && target->depth > 0
&& source->ancestors[source->depth - target->depth] == target))
return true;