From af983018bce8c0b369fd392e5cbc3996627a1527 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Thu, 5 Jul 2012 13:55:50 +0000 Subject: [PATCH] - improved debug messages, added break_op for malformed block --- src/mesh/gnunet-service-mesh_new.c | 7 +++++-- src/mesh/plugin_block_mesh.c | 21 +++++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/mesh/gnunet-service-mesh_new.c b/src/mesh/gnunet-service-mesh_new.c index 52485dcdd..23d462e22 100644 --- a/src/mesh/gnunet-service-mesh_new.c +++ b/src/mesh/gnunet-service-mesh_new.c @@ -740,8 +740,11 @@ regex_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof, " regex dht put for state %s\n", GNUNET_h2s(key)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - " proof: %s\n", + " proof: %s\n", proof); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + " num edges: %u\n", + num_edges); opt = GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE; if (GNUNET_YES == accepting) @@ -749,7 +752,7 @@ regex_iterator (void *cls, const struct GNUNET_HashCode *key, const char *proof, struct MeshRegexAccept block; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - " state %s is accepting, putting own id\n", + " state %s is accepting, putting own id\n", GNUNET_h2s(key)); size = sizeof (block); block.key = *key; diff --git a/src/mesh/plugin_block_mesh.c b/src/mesh/plugin_block_mesh.c index 1a530cdc0..8c080c485 100644 --- a/src/mesh/plugin_block_mesh.c +++ b/src/mesh/plugin_block_mesh.c @@ -87,20 +87,23 @@ block_plugin_mesh_evaluate (void *cls, enum GNUNET_BLOCK_Type type, } if (NULL == reply_block) return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; - if (sizeof (struct PBlock) != reply_block_size) - return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; + if (sizeof (struct PBlock) != reply_block_size) + { + GNUNET_break_op(0); + return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; + } if (NULL != bf) { GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash); GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash); if (NULL != *bf) { - if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash)) - return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; + if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash)) + return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE; } else { - *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K); + *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K); } GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash); } @@ -115,7 +118,10 @@ block_plugin_mesh_evaluate (void *cls, enum GNUNET_BLOCK_Type type, return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; if (GNUNET_OK != GNUNET_MESH_regex_block_check (reply_block, reply_block_size)) + { + GNUNET_break_op(0); return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; + } if (NULL != bf) { GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash); @@ -140,8 +146,11 @@ block_plugin_mesh_evaluate (void *cls, enum GNUNET_BLOCK_Type type, } if (NULL == reply_block) return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; - if (sizeof (struct MeshRegexAccept) != reply_block_size) + if (sizeof (struct MeshRegexAccept) != reply_block_size) + { + GNUNET_break_op(0); return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; + } if (NULL != bf) { GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash); -- 2.25.1