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

Skip to content
Snippets Groups Projects
Unverified Commit 9de618d6 authored by zzz's avatar zzz
Browse files

SSU2: Catch errors on bad ack blocks

so rest of payload can be processed
Improve debug output on errors
parent cdf77851
No related branches found
No related tags found
No related merge requests found
...@@ -567,12 +567,19 @@ public class PeerState2 extends PeerState implements SSU2Payload.PayloadCallback ...@@ -567,12 +567,19 @@ public class PeerState2 extends PeerState implements SSU2Payload.PayloadCallback
_log.debug("Got dup ACK block: " + SSU2Bitfield.toString(ackThru, acks, ranges, (ranges != null ? ranges.length / 2 : 0))); _log.debug("Got dup ACK block: " + SSU2Bitfield.toString(ackThru, acks, ranges, (ranges != null ? ranges.length / 2 : 0)));
return; return;
} }
SSU2Bitfield ackbf; try {
ackbf = SSU2Bitfield.fromACKBlock(ackThru, acks, ranges, (ranges != null ? ranges.length / 2 : 0)); SSU2Bitfield ackbf = SSU2Bitfield.fromACKBlock(ackThru, acks, ranges, (ranges != null ? ranges.length / 2 : 0));
if (_log.shouldDebug()) if (_log.shouldDebug())
_log.debug("Got new ACK block: " + SSU2Bitfield.toString(ackThru, acks, ranges, (ranges != null ? ranges.length / 2 : 0))); _log.debug("Got new ACK block: " + SSU2Bitfield.toString(ackThru, acks, ranges, (ranges != null ? ranges.length / 2 : 0)));
// calls bitSet() below // calls bitSet() below
ackbf.forEachAndNot(_ackedMessages, this); ackbf.forEachAndNot(_ackedMessages, this);
} catch (Exception e) {
// IllegalArgumentException, buggy ack block, let the other blocks get processed
if (_log.shouldWarn())
_log.warn("Bad ACK block\n" + SSU2Bitfield.toString(ackThru, acks, ranges, (ranges != null ? ranges.length / 2 : 0)) +
"\nAck through " + ackThru + " acks " + acks + (ranges != null ? "\n" + HexDump.dump(ranges) : "") +
"\nfrom " + this, e);
}
} }
public void gotTermination(int reason, long count) { public void gotTermination(int reason, long count) {
......
...@@ -36,7 +36,7 @@ class SSU2Bitfield { ...@@ -36,7 +36,7 @@ class SSU2Bitfield {
*/ */
public SSU2Bitfield(int size, long offset) { public SSU2Bitfield(int size, long offset) {
if (size <= 0 || offset < 0) if (size <= 0 || offset < 0)
throw new IllegalArgumentException(); throw new IllegalArgumentException("size " + size + " offset " + offset);
// force mult. of 256 // force mult. of 256
size = (size + 255) & 0x7FFFFF00; size = (size + 255) & 0x7FFFFF00;
this.size = size; this.size = 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