SSU2: Fix uncaught IAE caused by itags with zero values (Gitlab #415)

This commit is contained in:
zzz
2023-09-26 02:07:45 +00:00
committed by idk
parent 790584b329
commit 4cf919e3e6
2 changed files with 15 additions and 3 deletions

View File

@ -515,8 +515,16 @@ class EstablishmentManager {
} else if (version == 2) {
boolean requestIntroduction = !isIndirect &&
_transport.introducersMaybeRequired(TransportUtil.isIPv6(ra));
state = new OutboundEstablishState2(_context, _transport, maybeTo, to,
toIdentity, requestIntroduction, sessionKey, ra, addr);
try {
state = new OutboundEstablishState2(_context, _transport, maybeTo, to,
toIdentity, requestIntroduction, sessionKey, ra, addr);
} catch (IllegalArgumentException iae) {
if (_log.shouldWarn())
_log.warn("OES2 error: " + toRouterInfo, iae);
_transport.markUnreachable(toHash);
_transport.failed(msg, iae.getMessage());
return;
}
} else {
// shouldn't happen
_transport.failed(msg, "OB to bad addr? " + ra);

View File

@ -196,7 +196,7 @@ class OutboundEstablishState2 extends OutboundEstablishState implements SSU2Payl
_introducers.put(h, istate);
}
}
} else {
} else if (claimedAddress != null) {
_token = _transport.getEstablisher().getOutboundToken(_remoteHostId);
if (_token != 0) {
_currentState = OutboundState.OB_STATE_UNKNOWN;
@ -205,6 +205,10 @@ class OutboundEstablishState2 extends OutboundEstablishState implements SSU2Payl
_currentState = OutboundState.OB_STATE_NEEDS_TOKEN;
}
_introducers = null;
} else {
// i2pd bug fixed in 2.49.0/0.9.60, itag0-2 all zeros causes getIntroducerCount to be 0,
// which gets us here
throw new IllegalArgumentException("No address and no introducers for " + remotePeer.getHash());
}
_sendConnID = ctx.random().nextLong();