I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit ea00c0af authored by zzz's avatar zzz
Browse files

* SSU: Fix bug that would drop 512 byte messages

   The bug has been there forever but never happened before
   0.9.3 because the buffers were all 32KB and the largest
   fragment was about 1500 bytes. In 0.9.3, there are multiple
   buffer sizes, the smallest is 512 bytes, and a packet
   of exactly 512 bytes would be silently dropped.
   Thanks zab for finding it.
parent e6dbd7dd
No related branches found
No related tags found
No related merge requests found
......@@ -402,16 +402,21 @@ class OutboundMessageState implements CDPQEntry {
int end = start + fragmentSize(fragmentNum);
int toSend = end - start;
byte buf[] = _messageBuf.getData();
if ( (buf != null) && (start + toSend < buf.length) && (out != null) && (outOffset + toSend < out.length) ) {
System.arraycopy(_messageBuf.getData(), start, out, outOffset, toSend);
if ( (buf != null) && (start + toSend <= buf.length) && (outOffset + toSend <= out.length) ) {
System.arraycopy(buf, start, out, outOffset, toSend);
if (_log.shouldLog(Log.DEBUG))
_log.debug("Raw fragment[" + fragmentNum + "] for " + _messageId
+ "[" + start + "-" + (start+toSend) + "/" + _totalSize + "/" + _fragmentSize + "]: "
+ Base64.encode(out, outOffset, toSend));
return toSend;
} else if (buf == null) {
if (_log.shouldLog(Log.WARN))
_log.warn("Error: null buf");
} else {
return -1;
if (_log.shouldLog(Log.WARN))
_log.warn("Error: " + start + '/' + end + '/' + outOffset + '/' + out.length);
}
return -1;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment