aboutsummaryrefslogtreecommitdiff
path: root/src/consensus
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-02-26 23:39:29 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-02-26 23:39:29 +0100
commit82242cae3bb6313ee10df20570e4c14627828033 (patch)
treec628b5323c1ec8cbf0915e04bb7a1fa7864d7ea9 /src/consensus
parentcc8f37a834298d95c233769d19eb9cd17e3dbcfd (diff)
downloadgnunet-82242cae3bb6313ee10df20570e4c14627828033.tar.gz
gnunet-82242cae3bb6313ee10df20570e4c14627828033.zip
add validation for inner consensus element
The nested block validation requires the block context, and thus the evaluate callback not also receives the block context.
Diffstat (limited to 'src/consensus')
-rw-r--r--src/consensus/plugin_block_consensus.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/consensus/plugin_block_consensus.c b/src/consensus/plugin_block_consensus.c
index 39e348b18..3ad335760 100644
--- a/src/consensus/plugin_block_consensus.c
+++ b/src/consensus/plugin_block_consensus.c
@@ -35,6 +35,7 @@
35 * request evaluation, simply pass "NULL" for the reply_block. 35 * request evaluation, simply pass "NULL" for the reply_block.
36 * 36 *
37 * @param cls closure 37 * @param cls closure
38 * @param ctx context
38 * @param type block type 39 * @param type block type
39 * @param group block group to use 40 * @param group block group to use
40 * @param eo control flags 41 * @param eo control flags
@@ -47,6 +48,7 @@
47 */ 48 */
48static enum GNUNET_BLOCK_EvaluationResult 49static enum GNUNET_BLOCK_EvaluationResult
49block_plugin_consensus_evaluate (void *cls, 50block_plugin_consensus_evaluate (void *cls,
51 struct GNUNET_BLOCK_Context *ctx,
50 enum GNUNET_BLOCK_Type type, 52 enum GNUNET_BLOCK_Type type,
51 struct GNUNET_BLOCK_Group *group, 53 struct GNUNET_BLOCK_Group *group,
52 enum GNUNET_BLOCK_EvaluationOptions eo, 54 enum GNUNET_BLOCK_EvaluationOptions eo,
@@ -57,10 +59,23 @@ block_plugin_consensus_evaluate (void *cls,
57 size_t reply_block_size) 59 size_t reply_block_size)
58{ 60{
59 if (reply_block_size < sizeof (struct ConsensusElement)) 61 if (reply_block_size < sizeof (struct ConsensusElement))
60 {
61 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; 62 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
62 } 63
63 return GNUNET_BLOCK_EVALUATION_OK_MORE; 64 const struct ConsensusElement *ce = reply_block;
65
66 if ( (GNUNET_YES == ce->is_contested_marker) ||
67 (0 == ce->payload_type ) )
68 return GNUNET_BLOCK_EVALUATION_OK_MORE;
69
70 return GNUNET_BLOCK_evaluate (ctx,
71 type,
72 group,
73 eo,
74 query,
75 xquery,
76 xquery_size,
77 &ce[1],
78 reply_block_size - sizeof (struct ConsensusElement));
64} 79}
65 80
66 81