From bab9c4ab9624c1b2693e2e5820c1820fd32e6fb1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Philipp=20T=C3=B6lke?= Date: Fri, 8 Oct 2010 07:36:36 +0000 Subject: [PATCH] hash and validate a dns-block --- src/block/plugin_block_dns.c | 16 ++++++++++++++-- .../gnunet_block_dns.h} | 0 2 files changed, 14 insertions(+), 2 deletions(-) rename src/{vpn/gnunet-block-dns.h => include/gnunet_block_dns.h} (100%) diff --git a/src/block/plugin_block_dns.c b/src/block/plugin_block_dns.c index 743747c85..8435c1be0 100644 --- a/src/block/plugin_block_dns.c +++ b/src/block/plugin_block_dns.c @@ -26,6 +26,7 @@ #include "platform.h" #include "plugin_block.h" +#include "gnunet_block_dns.h" #define DEBUG_DHT GNUNET_NO @@ -60,9 +61,19 @@ block_plugin_dht_evaluate (void *cls, case GNUNET_BLOCK_TYPE_DNS: if (xquery_size != 0) return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; + if (reply_block_size == 0) return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; - return GNUNET_BLOCK_EVALUATION_OK_LAST; + + if (reply_block_size < sizeof(struct GNUNET_DNS_Record)) + return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; + + const struct GNUNET_DNS_Record* rec = reply_block; + if(reply_block_size != (sizeof(struct GNUNET_DNS_Record) + rec->namelen - 1)) + return GNUNET_BLOCK_EVALUATION_RESULT_INVALID; + + /* How to decide whether there are no more? */ + return GNUNET_BLOCK_EVALUATION_OK_MORE; default: return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; } @@ -89,7 +100,8 @@ block_plugin_dht_get_key (void *cls, { if (type != GNUNET_BLOCK_TYPE_DNS) return GNUNET_SYSERR; - return GNUNET_SYSERR; + GNUNET_CRYPTO_hash(block, block_size, key); + return GNUNET_OK; } /** diff --git a/src/vpn/gnunet-block-dns.h b/src/include/gnunet_block_dns.h similarity index 100% rename from src/vpn/gnunet-block-dns.h rename to src/include/gnunet_block_dns.h -- 2.25.1