From 151053e6aea2c91059843885748bbd10ff183e9b Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 18 Apr 2012 13:40:40 +0000 Subject: -fixing 2253 --- src/dht/gnunet-service-dht_routing.c | 12 ++++++++++++ src/dht/plugin_block_dht.c | 14 +++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'src/dht') 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) 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); } 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, 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); -- cgit v1.2.3