On Monday 14 April 2008 05:18, nextgens at freenetproject.org wrote:
> Author: nextgens
> Date: 2008-04-14 04:18:17 +0000 (Mon, 14 Apr 2008)
> New Revision: 19299
> 
> Modified:
>    trunk/freenet/src/freenet/node/FailureTable.java
> Log:
> prevent a potential array out of bounds

Please revert. If offers.length == 0 then idx will == -1 and therefore we will 
return and not get an error.
> 
> Modified: trunk/freenet/src/freenet/node/FailureTable.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/FailureTable.java  2008-04-14 04:09:28 UTC 
(rev 19298)
> +++ trunk/freenet/src/freenet/node/FailureTable.java  2008-04-14 04:18:17 UTC 
(rev 19299)
> @@ -158,14 +158,16 @@
>                                       if(offers[i] == offer) idx = i;
>                               }
>                               if(idx == -1) return;
> -                             BlockOffer[] newOffers = new 
> BlockOffer[offers.length-1];
> -                             if(idx > 0)
> -                                     System.arraycopy(offers, 0, newOffers, 
> 0, idx);
> -                             if(idx < newOffers.length)
> -                                     System.arraycopy(offers, idx+1, 
> newOffers, idx, offers.length-idx-1);
> -                             offers = newOffers;
> +                             if(offers.length > 1) {
> +                                     BlockOffer[] newOffers = new 
> BlockOffer[offers.length-1];
> +                                     if(idx > 0)
> +                                             System.arraycopy(offers, 0, 
> newOffers, 0, idx);
> +                                     if(idx < newOffers.length)
> +                                             System.arraycopy(offers, idx+1, 
> newOffers, idx, offers.length-idx-1);
> +                                     offers = newOffers;
> +                             }
>                       }
> -                     if(offers.length == 0) {
> +                     if(offers.length < 1) {
>                               synchronized(FailureTable.this) {
>                                       
> blockOfferListByKey.removeKey(entry.key);
>                               }
> 
> _______________________________________________
> cvs mailing list
> cvs at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 
<https://emu.freenetproject.org/pipermail/devl/attachments/20080414/5bb370e0/attachment.pgp>

Reply via email to