Array index out of bound inside natClass.cc (+patch)

Martin Kahlert martin.kahlert@infineon.com
Mon May 21 02:07:00 GMT 2001


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;
        



More information about the Java mailing list