diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-04-18 13:40:40 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-04-18 13:40:40 +0000 |
commit | 151053e6aea2c91059843885748bbd10ff183e9b (patch) | |
tree | ad9b4af8febf63ec94fc7fd8208d092281f577a7 | |
parent | 8dc9e1a5048dd74b1ded7551c9e6120e4c0476a5 (diff) | |
download | gnunet-151053e6aea2c91059843885748bbd10ff183e9b.tar.gz gnunet-151053e6aea2c91059843885748bbd10ff183e9b.zip |
-fixing 2253
-rw-r--r-- | src/block/plugin_block_test.c | 5 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht_routing.c | 12 | ||||
-rw-r--r-- | src/dht/plugin_block_dht.c | 14 | ||||
-rw-r--r-- | src/gns/plugin_block_gns.c | 11 |
4 files changed, 38 insertions, 4 deletions
diff --git a/src/block/plugin_block_test.c b/src/block/plugin_block_test.c index 08d3096dc..81e80e3ad 100644 --- a/src/block/plugin_block_test.c +++ b/src/block/plugin_block_test.c | |||
@@ -66,8 +66,11 @@ block_plugin_test_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
66 | if (type != GNUNET_BLOCK_TYPE_TEST) | 66 | if (type != GNUNET_BLOCK_TYPE_TEST) |
67 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | 67 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; |
68 | if (xquery_size != 0) | 68 | if (xquery_size != 0) |
69 | { | ||
70 | GNUNET_break_op (0); | ||
69 | return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; | 71 | return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; |
70 | if (reply_block_size == 0) | 72 | } |
73 | if (NULL == reply_block) | ||
71 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | 74 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; |
72 | 75 | ||
73 | if (NULL != bf) | 76 | if (NULL != bf) |
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); |
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c index 9d9513a09..dc92f6aec 100644 --- a/src/gns/plugin_block_gns.c +++ b/src/gns/plugin_block_gns.c | |||
@@ -88,9 +88,11 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
88 | * FIXME we could check for the record types here | 88 | * FIXME we could check for the record types here |
89 | **/ | 89 | **/ |
90 | if (xquery_size < sizeof(uint32_t)) | 90 | if (xquery_size < sizeof(uint32_t)) |
91 | { | ||
92 | GNUNET_break_op (0); | ||
91 | return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; | 93 | return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; |
92 | else | 94 | } |
93 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | 95 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; |
94 | } | 96 | } |
95 | 97 | ||
96 | /* this is a reply */ | 98 | /* this is a reply */ |
@@ -119,7 +121,10 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
119 | 121 | ||
120 | /* Check query key against public key */ | 122 | /* Check query key against public key */ |
121 | if (0 != GNUNET_CRYPTO_hash_cmp(query, &query_key)) | 123 | if (0 != GNUNET_CRYPTO_hash_cmp(query, &query_key)) |
124 | { | ||
125 | GNUNET_break_op (0); | ||
122 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | 126 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
127 | } | ||
123 | 128 | ||
124 | record_match = 0; | 129 | record_match = 0; |
125 | rd_count = ntohl(nrb->rd_count); | 130 | rd_count = ntohl(nrb->rd_count); |
@@ -139,6 +144,7 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
139 | { | 144 | { |
140 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 145 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
141 | "Data invalid (%d bytes, %d records)\n", rd_len, rd_count); | 146 | "Data invalid (%d bytes, %d records)\n", rd_len, rd_count); |
147 | GNUNET_break_op (0); | ||
142 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | 148 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
143 | } | 149 | } |
144 | 150 | ||
@@ -174,6 +180,7 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
174 | &nrb->signature)) | 180 | &nrb->signature)) |
175 | { | 181 | { |
176 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Signature invalid for name %s\n"); | 182 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Signature invalid for name %s\n"); |
183 | GNUNET_break_op (0); | ||
177 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; | 184 | return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; |
178 | } | 185 | } |
179 | } | 186 | } |