From 429280e41661fec2a81d6b098fb01f49db94525b Mon Sep 17 00:00:00 2001
From: dev <dev@welterde.de>
Date: Sat, 11 Apr 2009 20:28:15 +0000
Subject: [PATCH] fix a NPE

---
 .../net/i2p/router/transport/ntcp/EstablishState.java  | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/router/java/src/net/i2p/router/transport/ntcp/EstablishState.java b/router/java/src/net/i2p/router/transport/ntcp/EstablishState.java
index f8ccf0814d..cae5a99d2e 100644
--- a/router/java/src/net/i2p/router/transport/ntcp/EstablishState.java
+++ b/router/java/src/net/i2p/router/transport/ntcp/EstablishState.java
@@ -549,17 +549,21 @@ public class EstablishState {
             Signature sig = new Signature(s);
             _verified = _context.dsa().verifySignature(sig, toVerify, alice.getSigningPublicKey());
             if (_verified) {
-                byte[] ip = _con.getChannel().socket().getInetAddress().getAddress();
+				// get inet-addr
+				InetAddress addr = this._con.getChannel().socket().getInetAddress();
+                byte[] ip = (addr == null) ? null : addr.getAddress();
                 if (_context.shitlist().isShitlistedForever(alice.calculateHash())) {
                     if (_log.shouldLog(Log.WARN))
                         _log.warn("Dropping inbound connection from permanently shitlisted peer: " + alice.calculateHash().toBase64());
                     // So next time we will not accept the con from this IP,
                     // rather than doing the whole handshake
-                    _context.blocklist().add(ip);
+					if(ip != null)
+						_context.blocklist().add(ip);
                     fail("Peer is shitlisted forever: " + alice.calculateHash().toBase64());
                     return;
                 }
-                _transport.setIP(alice.calculateHash(), ip);
+				if(ip != null)
+					_transport.setIP(alice.calculateHash(), ip);
                 if (_log.shouldLog(Log.DEBUG))
                     _log.debug(prefix() + "verification successful for " + _con);
                                 
-- 
GitLab