Tunnel Endpoints:

- Reject type 3 (undefined) delivery instructions at both OBEP and IBEP,
     would be treated as LOCAL
   - Reject type 0 (LOCAL) delivery instructions at OBEP, no current usage,
     would cause NPE if handled
This commit is contained in:
zzz
2013-11-08 14:31:14 +00:00
parent 50f45a50a7
commit 67aead214b
2 changed files with 18 additions and 2 deletions

View File

@@ -277,10 +277,10 @@ class FragmentHandler {
/** for subsequent fragments, which bits contain the fragment #? */
private static final int MASK_FRAGMENT_NUM = (byte)((1 << 7) - 2); // 0x7E;
/** LOCAL isn't explicitly used anywhere, because the code knows that it is 0 */
static final short TYPE_LOCAL = 0;
static final short TYPE_TUNNEL = 1;
static final short TYPE_ROUTER = 2;
static final short TYPE_UNDEF = 3;
/**
* @return the offset for the next byte after the received fragment
@@ -350,7 +350,15 @@ class FragmentHandler {
int size = (int)DataHelper.fromLong(preprocessed, offset, 2);
offset += 2;
if (fragmented) {
if (type == TYPE_UNDEF) {
// do this after the above since we have to return offset
// no uses for TYPE_LOCAL yet
// OutboundTunnelEndpoint doesn't check for null Hash, passes it
// to OutboundMessageDistributor.distribute() which will NPE
if (_log.shouldLog(Log.WARN))
_log.warn("Dropping msg at tunnel endpoint with unsupported delivery instruction type " +
type + " rcvr: " + _receiver);
} else if (fragmented) {
FragmentedMessage msg;
synchronized (_fragmentedMessages) {
msg = _fragmentedMessages.get(Long.valueOf(messageId));

View File

@@ -47,6 +47,14 @@ class OutboundTunnelEndpoint {
private class DefragmentedHandler implements FragmentHandler.DefragmentedReceiver {
public void receiveComplete(I2NPMessage msg, Hash toRouter, TunnelId toTunnel) {
if (toRouter == null) {
// Delivery type LOCAL is not supported at the OBEP
// We don't have any use for it yet.
// Don't send to OutboundMessageDistributor.distribute() which will NPE or fail
if (_log.shouldLog(Log.WARN))
_log.warn("Dropping msg at OBEP with unsupported delivery instruction type LOCAL");
return;
}
if (_log.shouldLog(Log.DEBUG))
_log.debug("outbound tunnel " + _config + " received a full message: " + msg
+ " to be forwarded on to "