Author: robert
Date: 2008-03-04 23:56:42 +0000 (Tue, 04 Mar 2008)
New Revision: 18364

Modified:
   trunk/freenet/src/freenet/node/FailureTable.java
Log:
DoS: check validity of request *before* hitting the datastore


Modified: trunk/freenet/src/freenet/node/FailureTable.java
===================================================================
--- trunk/freenet/src/freenet/node/FailureTable.java    2008-03-04 23:28:15 UTC 
(rev 18363)
+++ trunk/freenet/src/freenet/node/FailureTable.java    2008-03-04 23:56:42 UTC 
(rev 18364)
@@ -244,10 +244,6 @@
                if(!node.enableULPRDataPropagation) return;
                if(logMINOR)
                        Logger.minor(this, "Offered key "+key+" by peer "+peer);
-               if(node.hasKey(key)) {
-                       Logger.minor(this, "Already have key");
-                       return;
-               }
                FailureTableEntry entry;
                long now = System.currentTimeMillis();
                synchronized(this) {
@@ -257,6 +253,11 @@
                                return; // we haven't asked for it
                        }
                }
+               //NB: node.hasKey() executes a datastore fetch
+               if(node.hasKey(key)) {
+                       Logger.minor(this, "Already have key");
+                       return;
+               }               
                /*
                 * Accept (subject to later checks) if we asked for it.
                 * Should we accept it if we were asked for it? This is 
"bidirectional propagation".


Reply via email to