aboutsummaryrefslogtreecommitdiff
path: root/src/dht
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-04-18 13:40:40 +0000
committerChristian Grothoff <christian@grothoff.org>2012-04-18 13:40:40 +0000
commit151053e6aea2c91059843885748bbd10ff183e9b (patch)
treead9b4af8febf63ec94fc7fd8208d092281f577a7 /src/dht
parent8dc9e1a5048dd74b1ded7551c9e6120e4c0476a5 (diff)
downloadgnunet-151053e6aea2c91059843885748bbd10ff183e9b.tar.gz
gnunet-151053e6aea2c91059843885748bbd10ff183e9b.zip
-fixing 2253
Diffstat (limited to 'src/dht')
-rw-r--r--src/dht/gnunet-service-dht_routing.c12
-rw-r--r--src/dht/plugin_block_dht.c14
2 files changed, 25 insertions, 1 deletions
diff --git a/src/dht/gnunet-service-dht_routing.c b/src/dht/gnunet-service-dht_routing.c
index a880bf7cd..2600b4460 100644
--- a/src/dht/gnunet-service-dht_routing.c
+++ b/src/dht/gnunet-service-dht_routing.c
@@ -227,6 +227,8 @@ process (void *cls, const GNUNET_HashCode * key, void *value)
227 1, GNUNET_NO); 227 1, GNUNET_NO);
228 return GNUNET_SYSERR; 228 return GNUNET_SYSERR;
229 case GNUNET_BLOCK_EVALUATION_REQUEST_VALID: 229 case GNUNET_BLOCK_EVALUATION_REQUEST_VALID:
230 GNUNET_break (0);
231 return GNUNET_OK;
230 case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID: 232 case GNUNET_BLOCK_EVALUATION_REQUEST_INVALID:
231 GNUNET_break (0); 233 GNUNET_break (0);
232 return GNUNET_OK; 234 return GNUNET_OK;
@@ -280,6 +282,16 @@ GDS_ROUTING_process (enum GNUNET_BLOCK_Type type,
280 pc.get_path = get_path; 282 pc.get_path = get_path;
281 pc.data = data; 283 pc.data = data;
282 pc.data_size = data_size; 284 pc.data_size = data_size;
285 if (NULL == data)
286 {
287 /* Some apps might have an 'empty' reply as a valid reply; however,
288 'process' will call GNUNET_BLOCK_evaluate' which treats a 'NULL'
289 reply as request-validation (but we need response-validation).
290 So we set 'data' to a 0-byte non-NULL value just to be sure */
291 GNUNET_break (0 == data_size);
292 data_size = 0;
293 pc.data = ""; /* something not null */
294 }
283 GNUNET_CONTAINER_multihashmap_get_multiple (recent_map, key, &process, &pc); 295 GNUNET_CONTAINER_multihashmap_get_multiple (recent_map, key, &process, &pc);
284} 296}
285 297
diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c
index 19467b9c9..3c016aedc 100644
--- a/src/dht/plugin_block_dht.c
+++ b/src/dht/plugin_block_dht.c
@@ -65,17 +65,29 @@ block_plugin_dht_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
65 if (type != GNUNET_BLOCK_TYPE_DHT_HELLO) 65 if (type != GNUNET_BLOCK_TYPE_DHT_HELLO)
66 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; 66 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
67 if (xquery_size != 0) 67 if (xquery_size != 0)
68 {
69 GNUNET_break_op (0);
68 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; 70 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
69 if (reply_block_size == 0) 71 }
72 if (NULL == reply_block)
70 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; 73 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
71 if (reply_block_size < sizeof (struct GNUNET_MessageHeader)) 74 if (reply_block_size < sizeof (struct GNUNET_MessageHeader))
75 {
76 GNUNET_break_op (0);
72 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; 77 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
78 }
73 msg = reply_block; 79 msg = reply_block;
74 if (reply_block_size != ntohs (msg->size)) 80 if (reply_block_size != ntohs (msg->size))
81 {
82 GNUNET_break_op (0);
75 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; 83 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
84 }
76 hello = reply_block; 85 hello = reply_block;
77 if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid)) 86 if (GNUNET_OK != GNUNET_HELLO_get_id (hello, &pid))
87 {
88 GNUNET_break_op (0);
78 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; 89 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
90 }
79 if (NULL != bf) 91 if (NULL != bf)
80 { 92 {
81 GNUNET_BLOCK_mingle_hash (&pid.hashPubKey, bf_mutator, &mhash); 93 GNUNET_BLOCK_mingle_hash (&pid.hashPubKey, bf_mutator, &mhash);