-fixing 2253
authorChristian Grothoff <christian@grothoff.org>
Wed, 18 Apr 2012 13:40:40 +0000 (13:40 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 18 Apr 2012 13:40:40 +0000 (13:40 +0000)
src/block/plugin_block_test.c
src/dht/gnunet-service-dht_routing.c
src/dht/plugin_block_dht.c
src/gns/plugin_block_gns.c

index 08d3096dc24bfa8c4668be0345d254aa4f6553d5..81e80e3ad993edaaaf61a7ba898969d16b3f0ec8 100644 (file)
@@ -66,8 +66,11 @@ block_plugin_test_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
   if (type != GNUNET_BLOCK_TYPE_TEST)
     return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
   if (xquery_size != 0)
+  {
+    GNUNET_break_op (0);
     return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
-  if (reply_block_size == 0)
+  }
+  if (NULL == reply_block)
     return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
 
   if (NULL != bf)
index a880bf7cd9010d4b457bb7221c55a5e444c4523e..2600b44602898394e512dc6b8631727a8acbbd55 100644 (file)
@@ -227,6 +227,8 @@ process (void *cls, const GNUNET_HashCode * key, void *value)
                               1, GNUNET_NO);
     return GNUNET_SYSERR;
   case GNUNET_BLOCK_EVALUATION_REQUEST_VALID:
+    GNUNET_break (0);
+    return GNUNET_OK;
   case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID:
     GNUNET_break (0);
     return GNUNET_OK;
@@ -280,6 +282,16 @@ GDS_ROUTING_process (enum GNUNET_BLOCK_Type type,
   pc.get_path = get_path;
   pc.data = data;
   pc.data_size = data_size;
+  if (NULL == data)
+  {
+    /* Some apps might have an 'empty' reply as a valid reply; however,
+       'process' will call GNUNET_BLOCK_evaluate' which treats a 'NULL'
+       reply as request-validation (but we need response-validation).
+       So we set 'data' to a 0-byte non-NULL value just to be sure */
+    GNUNET_break (0 == data_size);
+    data_size = 0;
+    pc.data = ""; /* something not null */
+  }
   GNUNET_CONTAINER_multihashmap_get_multiple (recent_map, key, &process, &pc);
 }
 
index 19467b9c96b207b8c8ce2025ce89adc9b8f26faf..3c016aedcdb3b14ff839e3ac644eb01af4be1d68 100644 (file)
@@ -65,17 +65,29 @@ block_plugin_dht_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
   if (type != GNUNET_BLOCK_TYPE_DHT_HELLO)
     return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
   if (xquery_size != 0)
+  {
+    GNUNET_break_op (0);
     return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
-  if (reply_block_size == 0)
+  }
+  if (NULL == reply_block)
     return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
   if (reply_block_size < sizeof (struct GNUNET_MessageHeader))
+  {
+    GNUNET_break_op (0);
     return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+  }
   msg = reply_block;
   if (reply_block_size != ntohs (msg->size))
+  {
+    GNUNET_break_op (0);
     return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+  }
   hello = reply_block;
   if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid))
+  {
+    GNUNET_break_op (0);
     return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+  }
   if (NULL != bf)
   {
     GNUNET_BLOCK_mingle_hash (&pid.hashPubKey, bf_mutator, &mhash);
index 9d9513a09663ec9e8ae48c330b33227fd24aee35..dc92f6aecc832d2490f4df415de50fd3b409c06f 100644 (file)
@@ -88,9 +88,11 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
      *  FIXME we could check for the record types here
      **/
     if (xquery_size < sizeof(uint32_t))
+    {
+      GNUNET_break_op (0);
       return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
-    else
-      return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
+    }
+    return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
   }
   
   /* this is a reply */
@@ -119,7 +121,10 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
 
   /* Check query key against public key */
   if (0 != GNUNET_CRYPTO_hash_cmp(query, &query_key))
+  {
+    GNUNET_break_op (0);
     return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+  }
   
   record_match = 0;
   rd_count = ntohl(nrb->rd_count);
@@ -139,6 +144,7 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
     {
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
                  "Data invalid (%d bytes, %d records)\n", rd_len, rd_count);
+      GNUNET_break_op (0);
       return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
     }
 
@@ -174,6 +180,7 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
                                                         &nrb->signature))
     {
       GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Signature invalid for name %s\n");
+      GNUNET_break_op (0);
       return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
     }
   }