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

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

avoid two NPEs on corrupt fragments

parent 321f11c0
No related branches found
No related tags found
No related merge requests found
...@@ -372,6 +372,8 @@ public class FragmentHandler { ...@@ -372,6 +372,8 @@ public class FragmentHandler {
int fragmentCount = msg.getFragmentCount(); int fragmentCount = msg.getFragmentCount();
// toByteArray destroys the contents of the message completely // toByteArray destroys the contents of the message completely
byte data[] = msg.toByteArray(); byte data[] = msg.toByteArray();
if (data == null)
throw new I2NPMessageException("null data"); // fragments already released???
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("RECV(" + data.length + "): " + Base64.encode(data) _log.debug("RECV(" + data.length + "): " + Base64.encode(data)
+ " " + _context.sha().calculateHash(data).toBase64()); + " " + _context.sha().calculateHash(data).toBase64());
......
...@@ -189,6 +189,9 @@ public class FragmentedMessage { ...@@ -189,6 +189,9 @@ public class FragmentedMessage {
int size = 0; int size = 0;
for (int i = 0; i <= _highFragmentNum; i++) { for (int i = 0; i <= _highFragmentNum; i++) {
ByteArray ba = _fragments[i]; ByteArray ba = _fragments[i];
// NPE seen here, root cause unknown
if (ba == null)
throw new IllegalStateException("wtf, don't get the completed size when we're not complete - null fragment i=" + i + " of " + _highFragmentNum);
size += ba.getValid(); size += ba.getValid();
} }
return size; return size;
......
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