aboutsummaryrefslogtreecommitdiff
path: root/src/gns/plugin_block_gns.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-10-26 22:13:01 +0000
committerChristian Grothoff <christian@grothoff.org>2012-10-26 22:13:01 +0000
commit64d3e46cfb99a711e500fa1f114e7c44bdf10040 (patch)
tree83093d92761d5c1b8b2fded713adaa19af29274c /src/gns/plugin_block_gns.c
parentef6f05f63769263a5201636c4b7f71eaa455cdf3 (diff)
downloadgnunet-64d3e46cfb99a711e500fa1f114e7c44bdf10040.tar.gz
gnunet-64d3e46cfb99a711e500fa1f114e7c44bdf10040.zip
-bugfixes, code cleanup
Diffstat (limited to 'src/gns/plugin_block_gns.c')
-rw-r--r--src/gns/plugin_block_gns.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c
index a2faecf2d..d8da01f5b 100644
--- a/src/gns/plugin_block_gns.c
+++ b/src/gns/plugin_block_gns.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 (C) 2010 Christian Grothoff (and other contributing authors) 3 (C) 2010, 2012 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -63,17 +63,19 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
63 size_t xquery_size, const void *reply_block, 63 size_t xquery_size, const void *reply_block,
64 size_t reply_block_size) 64 size_t reply_block_size)
65{ 65{
66 const struct GNSNameRecordBlock *nrb;
66 const char* name; 67 const char* name;
68 const char *name_end;
69 const char *rd_data;
67 struct GNUNET_HashCode query_key; 70 struct GNUNET_HashCode query_key;
68 struct GNUNET_HashCode mhash; 71 struct GNUNET_HashCode mhash;
69 struct GNUNET_HashCode chash; 72 struct GNUNET_HashCode chash;
70 struct GNUNET_CRYPTO_ShortHashCode pkey_hash; 73 struct GNUNET_CRYPTO_ShortHashCode pkey_hash;
71 struct GNSNameRecordBlock *nrb;
72 struct GNUNET_CRYPTO_HashAsciiEncoded xor_exp; 74 struct GNUNET_CRYPTO_HashAsciiEncoded xor_exp;
73 struct GNUNET_CRYPTO_HashAsciiEncoded xor_got; 75 struct GNUNET_CRYPTO_HashAsciiEncoded xor_got;
74 uint32_t rd_count; 76 uint32_t rd_count;
75 char* rd_data = NULL; 77 size_t rd_len;
76 int rd_len; 78 size_t name_len;
77 uint32_t record_xquery; 79 uint32_t record_xquery;
78 unsigned int record_match; 80 unsigned int record_match;
79 81
@@ -97,9 +99,15 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
97 99
98 /* this is a reply */ 100 /* this is a reply */
99 101
100 nrb = (struct GNSNameRecordBlock *)reply_block; 102 nrb = (const struct GNSNameRecordBlock *)reply_block;
101 name = (const char*)&nrb[1]; 103 name = (const char*) &nrb[1];
102 104 name_end = memchr (name, 0, reply_block_size - sizeof (struct GNSNameRecordBlock));
105 if (NULL == name_end)
106 {
107 GNUNET_break_op (0);
108 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
109 }
110 name_len = (name_end - name) + 1;
103 GNUNET_CRYPTO_short_hash (&nrb->public_key, 111 GNUNET_CRYPTO_short_hash (&nrb->public_key,
104 sizeof(nrb->public_key), 112 sizeof(nrb->public_key),
105 &pkey_hash); 113 &pkey_hash);
@@ -121,9 +129,8 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
121 129
122 record_match = 0; 130 record_match = 0;
123 rd_count = ntohl(nrb->rd_count); 131 rd_count = ntohl(nrb->rd_count);
124 rd_data = (char*)&nrb[1]; 132 rd_data = &name[name_len];
125 rd_data += strlen(name) + 1; 133 rd_len = reply_block_size - (name_len
126 rd_len = reply_block_size - (strlen(name) + 1
127 + sizeof(struct GNSNameRecordBlock)); 134 + sizeof(struct GNSNameRecordBlock));
128 { 135 {
129 struct GNUNET_NAMESTORE_RecordData rd[rd_count]; 136 struct GNUNET_NAMESTORE_RecordData rd[rd_count];