Author: toad
Date: 2008-07-21 21:47:08 +0000 (Mon, 21 Jul 2008)
New Revision: 21298

Modified:
   branches/db4o/freenet/src/freenet/node/FNPPacketMangler.java
Log:
Prevent an NPE. BACKPORT *if* there isn't already similar code in trunk.

Modified: branches/db4o/freenet/src/freenet/node/FNPPacketMangler.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/FNPPacketMangler.java        
2008-07-21 21:39:21 UTC (rev 21297)
+++ branches/db4o/freenet/src/freenet/node/FNPPacketMangler.java        
2008-07-21 21:47:08 UTC (rev 21298)
@@ -1253,6 +1253,15 @@
                BlockCipher c = null;
                try { c = new Rijndael(256, 256); } catch 
(UnsupportedCipherException e) {}

+               if(bothNoderefs && pn.jfkMyRef == null) {
+                       if(node.getUptime() < 60*1000) {
+                               Logger.normal(this, "Avoiding NPE: got JFK(4) 
but no pn.jfkMyRef on "+pn);
+                               return false;
+                       } else {
+                               Logger.error(this, "Got JFK(4) but no 
pn.jfkMyRef on "+pn);
+                               return false;
+                       }
+               }
                final int expectedLength =
                        HASH_LENGTH + // HMAC of the cyphertext
                        (c.getBlockSize() >> 3) + // IV


Reply via email to