* I2NP: Various cleanup and bulletproofing

This commit is contained in:
zzz
2010-01-26 19:59:39 +00:00
parent ccc95087a1
commit 164b39d8df
9 changed files with 76 additions and 51 deletions

View File

@@ -22,8 +22,6 @@ public class DataMessage extends I2NPMessageImpl {
public final static int MESSAGE_TYPE = 20;
private byte _data[];
// private static final int MAX_SIZE = 64*1024; // LINT -- field hides another field, and not used
public DataMessage(I2PAppContext context) {
super(context);
_data = null;
@@ -48,7 +46,7 @@ public class DataMessage extends I2NPMessageImpl {
int curIndex = offset;
long size = DataHelper.fromLong(data, curIndex, 4);
curIndex += 4;
if (size > 64*1024)
if (size > MAX_SIZE)
throw new I2NPMessageException("wtf, size=" + size);
_data = new byte[(int)size];
System.arraycopy(data, curIndex, _data, 0, (int)size);