enforce some sanity checks on the payload size. see recent rant in DatabaseSearchReplyMessage commit for why

this is necessary.
This commit is contained in:
jrandom
2004-06-19 23:58:24 +00:00
committed by zzz
parent 592519c45c
commit bbf73f0937

View File

@ -27,6 +27,8 @@ public class DataMessage extends I2NPMessageImpl {
public final static int MESSAGE_TYPE = 20;
private byte _data[];
private static final int MAX_SIZE = 64*1024;
public DataMessage(I2PAppContext context) {
super(context);
_data = null;
@ -41,6 +43,8 @@ public class DataMessage extends I2NPMessageImpl {
if (type != MESSAGE_TYPE) throw new I2NPMessageException("Message type is incorrect for this message");
try {
int size = (int)DataHelper.readLong(in, 4);
if ( (size <= 0) || (size > MAX_SIZE) )
throw new I2NPMessageException("wtf, size out of range? " + size);
_data = new byte[size];
int read = read(in, _data);
if (read != size)