[kaffe] CVS kaffe (guilhem): Integer overflow fix in System.arraycopy

Kaffe CVS cvs-commits at kaffe.org
Sun Apr 3 13:48:44 PDT 2005


PatchSet 5657 
Date: 2005/04/03 20:43:28
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Integer overflow fix in System.arraycopy

2005-04-03  Guilhem Lavaux  <guilhem at kaffe.org>,
        Mark Wielaard <mark at klomp.org>

        * libraries/javalib/java/lang/System.java
        (arraycopy): Cast to long to prevent integer overflow.

Members: 
	ChangeLog:1.3827->1.3828 
	libraries/javalib/java/lang/System.java:1.45->1.46 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3827 kaffe/ChangeLog:1.3828
--- kaffe/ChangeLog:1.3827	Sun Apr  3 19:20:25 2005
+++ kaffe/ChangeLog	Sun Apr  3 20:43:28 2005
@@ -1,3 +1,9 @@
+2005-04-03  Guilhem Lavaux  <guilhem at kaffe.org>,
+	Mark Wielaard <mark at klomp.org>
+	
+	* libraries/javalib/java/lang/System.java
+	(arraycopy): Cast to long to prevent integer overflow.
+
 2005-04-03  Dalibor Topic  <robilad at kaffe.org>
 
 	* config/ia64/hpux/config.frag,
Index: kaffe/libraries/javalib/java/lang/System.java
diff -u kaffe/libraries/javalib/java/lang/System.java:1.45 kaffe/libraries/javalib/java/lang/System.java:1.46
--- kaffe/libraries/javalib/java/lang/System.java:1.45	Wed Jan  5 20:06:43 2005
+++ kaffe/libraries/javalib/java/lang/System.java	Sun Apr  3 20:43:31 2005
@@ -79,7 +79,7 @@
 
     final int src_length = Array.getLength(src);
 
-    if (src_position + length > src_length)
+    if ((long)src_position + (long)length > (long)src_length)
 	throw new ArrayIndexOutOfBoundsException("src_position + length > src.length: " + src_position + " + " + length + " > " + src_length);
 
     if (dst_position < 0)
@@ -87,7 +87,7 @@
 
     final int dst_length = Array.getLength(dst);
 
-    if (dst_position + length > dst_length)
+    if ((long)dst_position + (long)length > (long)dst_length)
 	throw new ArrayIndexOutOfBoundsException("dst_position + length > dst.length: " + dst_position + " + " + length + " > " + dst_length);
 
     if (length < 0)




More information about the kaffe mailing list