Author: robert
Date: 2008-03-11 20:13:36 +0000 (Tue, 11 Mar 2008)
New Revision: 18475

Modified:
   trunk/freenet/src/freenet/node/PeerNode.java
Log:
input validation: don't throw an ArrayIndexOutOfBoundsException


Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java        2008-03-11 20:11:33 UTC 
(rev 18474)
+++ trunk/freenet/src/freenet/node/PeerNode.java        2008-03-11 20:13:36 UTC 
(rev 18475)
@@ -3344,7 +3344,11 @@
                        short notFoundCount = 0;
                        short consecutiveNotFound = 0;
                        short longestConsecutiveNotFound = 0;
-                       for(short i = (short) (times.length-1); i >= 0; i--) {
+                       //The arrays are constructed from received data, don't 
throw an ArrayIndexOutOfBoundsException if they are different sizes.
+                       int shortestArray=times.length;
+                       if (shortestArray > packetHashes.length)
+                               shortestArray = packetHashes.length;
+                       for(short i = (short) (shortestArray-1); i >= 0; i--) { 
                                long time = times[i];
                                if(time > otime) {
                                        Logger.error(this, "Inconsistent time 
order: [" + i + "]=" + time + " but [" + (i + 1) + "] is " + otime);


Reply via email to