2005-12-26 Complication

* Fix some integer typecasting in I2PSnark (caused >2GB torrents to fail)
    * HTML readability cosmetics on "Peers" page
This commit is contained in:
complication
2005-12-27 04:20:29 +00:00
committed by zzz
parent dc0485b526
commit 9b7e5d1817
5 changed files with 18 additions and 9 deletions

View File

@ -39,8 +39,8 @@ public class Storage
private final StorageListener listener; private final StorageListener listener;
private final BitField bitfield; private final BitField bitfield; // BitField to represent the pieces
private int needed; private int needed; // Number of pieces needed
// XXX - Not always set correctly // XXX - Not always set correctly
int piece_size; int piece_size;
@ -506,7 +506,8 @@ public class Storage
} }
} }
long start = piece * metainfo.getPieceLength(0); // Early typecast, avoid possibly overflowing a temp integer
long start = (long) piece * (long) metainfo.getPieceLength(0);
int i = 0; int i = 0;
long raflen = lengths[i]; long raflen = lengths[i];
while (start > raflen) while (start > raflen)
@ -549,7 +550,10 @@ public class Storage
throws IOException throws IOException
{ {
// XXX - copy/paste code from putPiece(). // XXX - copy/paste code from putPiece().
long start = piece * metainfo.getPieceLength(0);
// Early typecast, avoid possibly overflowing a temp integer
long start = (long) piece * (long) metainfo.getPieceLength(0);
int length = metainfo.getPieceLength(piece); int length = metainfo.getPieceLength(piece);
int i = 0; int i = 0;
long raflen = lengths[i]; long raflen = lengths[i];

View File

@ -333,7 +333,8 @@ public class I2PSnarkServlet extends HttpServlet {
if (filename.length() > MAX_DISPLAYED_FILENAME_LENGTH) if (filename.length() > MAX_DISPLAYED_FILENAME_LENGTH)
filename = filename.substring(0, MAX_DISPLAYED_FILENAME_LENGTH) + "..."; filename = filename.substring(0, MAX_DISPLAYED_FILENAME_LENGTH) + "...";
long total = snark.meta.getTotalLength(); long total = snark.meta.getTotalLength();
long remaining = snark.storage.needed() * snark.meta.getPieceLength(0); // Early typecast, avoid possibly overflowing a temp integer
long remaining = (long) snark.storage.needed() * (long) snark.meta.getPieceLength(0);
if (remaining > total) if (remaining > total)
remaining = total; remaining = total;
int totalBps = 4096; // should probably grab this from the snark... int totalBps = 4096; // should probably grab this from the snark...

View File

@ -1,4 +1,8 @@
$Id: history.txt,v 1.368 2005/12/22 05:10:39 jrandom Exp $ $Id: history.txt,v 1.369 2005/12/22 07:49:09 jrandom Exp $
2005-12-26 Complication
* Fix some integer typecasting in I2PSnark (caused >2GB torrents to fail)
* HTML readability cosmetics on "Peers" page
* 2005-12-22 0.6.1.8 released * 2005-12-22 0.6.1.8 released

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
* *
*/ */
public class RouterVersion { public class RouterVersion {
public final static String ID = "$Revision: 1.316 $ $Date: 2005/12/22 05:04:13 $"; public final static String ID = "$Revision: 1.317 $ $Date: 2005/12/22 07:49:09 $";
public final static String VERSION = "0.6.1.8"; public final static String VERSION = "0.6.1.8";
public final static long BUILD = 0; public final static long BUILD = 1;
public static void main(String args[]) { public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION + "-" + BUILD); System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
System.out.println("Router ID: " + RouterVersion.ID); System.out.println("Router ID: " + RouterVersion.ID);

View File

@ -1161,7 +1161,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
buf.append(dupRecv); //formatPct(recvDupPct)); buf.append(dupRecv); //formatPct(recvDupPct));
buf.append("</code></td>"); buf.append("</code></td>");
buf.append("</tr>"); buf.append("</tr>\n");
out.write(buf.toString()); out.write(buf.toString());
buf.setLength(0); buf.setLength(0);