[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
java.io.ObjectInputStream throws ArrayIndexOutOfBoundsException
From: |
Ito Kazumitsu |
Subject: |
java.io.ObjectInputStream throws ArrayIndexOutOfBoundsException |
Date: |
Tue, 10 Feb 2004 07:14:54 +0900 |
User-agent: |
EMH/1.10.0 SEMI/1.13.7 (Awazu) FLIM/1.13.2 (Kasanui) Emacs/21.2 (i386-unknown-freebsd4.7) MULE/5.0 (SAKAKI) |
Hi,
As reported in the Kaffe mailing list[1], java.io.ObjectInputStream
throws ArrayIndexOutOfBoundsException in some unusual case.
[1] http://www.kaffe.org/pipermail/kaffe/2004-February/045180.html
And here is my proposed patch.
ChangeLog entry:
2004-02-09 Ito Kazumitsu <address@hidden>
* java/io/ObjectInputStream.java
(readClassDescriptor):
Avoid the overflow of fieldmapping.
--- java/io/ObjectInputStream.java.orig Tue Feb 3 07:28:42 2004
+++ java/io/ObjectInputStream.java Tue Feb 10 00:51:45 2004
@@ -491,7 +491,6 @@
ObjectStreamField[] stream_fields = osc.fields;
ObjectStreamField[] real_fields = ObjectStreamClass.lookup(clazz).fields;
ObjectStreamField[] fieldmapping = new ObjectStreamField[2 *
Math.max(stream_fields.length, real_fields.length)];
- osc.fieldMapping = fieldmapping;
int stream_idx = 0;
int real_idx = 0;
@@ -543,9 +542,21 @@
}
if (real_field != null && !real_field.isToSet())
real_field = null;
+ /* If some of stream_fields does not correspond to any of real_fields,
+ * or the opposite, then fieldmapping will go short.
+ */
+ if (map_idx == fieldmapping.length)
+ {
+ ObjectStreamField[] newfieldmapping =
+ new ObjectStreamField[fieldmapping.length + 2];
+ System.arraycopy(fieldmapping, 0,
+ newfieldmapping, 0, fieldmapping.length);
+ fieldmapping = newfieldmapping;
+ }
fieldmapping[map_idx++] = stream_field;
fieldmapping[map_idx++] = real_field;
}
+ osc.fieldMapping = fieldmapping;
return osc;
}
- java.io.ObjectInputStream throws ArrayIndexOutOfBoundsException,
Ito Kazumitsu <=