fix warning / add size validation for consensus block
authorFlorian Dold <florian.dold@gmail.com>
Sun, 26 Feb 2017 22:12:40 +0000 (23:12 +0100)
committerFlorian Dold <florian.dold@gmail.com>
Sun, 26 Feb 2017 22:12:40 +0000 (23:12 +0100)
src/consensus/consensus_protocol.h
src/consensus/plugin_block_consensus.c

index 101b8aee7b908216522214a72a8c202c5ffd6a96..161c939cdd3e4bf8eccdb6578d9cf1d659ed19fb 100644 (file)
@@ -29,6 +29,7 @@
 #define GNUNET_CONSENSUS_PROTOCOL_H
 
 #include "platform.h"
+#include "gnunet_util_lib.h"
 #include "gnunet_common.h"
 #include "gnunet_protocols.h"
 
index 399e85feb418193de607444cb8e7d9b4d4263ed4..39e348b18eeabb5804e38c8405c71e8b5190b50a 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include "platform.h"
+#include "consensus_protocol.h"
 #include "gnunet_block_plugin.h"
 #include "gnunet_block_group_lib.h"
 
@@ -55,6 +56,10 @@ block_plugin_consensus_evaluate (void *cls,
                                  const void *reply_block,
                                  size_t reply_block_size)
 {
+  if (reply_block_size < sizeof (struct ConsensusElement))
+  {
+    return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
+  }
   return GNUNET_BLOCK_EVALUATION_OK_MORE;
 }