aboutsummaryrefslogtreecommitdiff
path: root/src/namecache
diff options
context:
space:
mode:
authorSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2018-06-24 23:19:58 +0200
committerSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2018-06-24 23:19:58 +0200
commit67233f623f8695a1e545aeebae0f9cb2df5dc84f (patch)
tree3b708cc2a83487ce7bc3aec857420f295f994447 /src/namecache
parentc6dc6e0b72b89baa94872c7e250b3b59de382499 (diff)
downloadgnunet-67233f623f8695a1e545aeebae0f9cb2df5dc84f.tar.gz
gnunet-67233f623f8695a1e545aeebae0f9cb2df5dc84f.zip
handle corrupted names in cache
Diffstat (limited to 'src/namecache')
-rw-r--r--src/namecache/gnunet-service-namecache.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/namecache/gnunet-service-namecache.c b/src/namecache/gnunet-service-namecache.c
index cda1267e8..9130ed0a4 100644
--- a/src/namecache/gnunet-service-namecache.c
+++ b/src/namecache/gnunet-service-namecache.c
@@ -148,7 +148,11 @@ struct LookupBlockContext
148 * Operation id for the name lookup 148 * Operation id for the name lookup
149 */ 149 */
150 uint32_t request_id; 150 uint32_t request_id;
151 151
152 /**
153 * Lookup status
154 */
155 uint32_t status;
152}; 156};
153 157
154 158
@@ -166,7 +170,17 @@ handle_lookup_block_it (void *cls,
166 struct GNUNET_MQ_Envelope *env; 170 struct GNUNET_MQ_Envelope *env;
167 struct LookupBlockResponseMessage *r; 171 struct LookupBlockResponseMessage *r;
168 size_t esize; 172 size_t esize;
173 size_t bsize;
169 174
175 bsize = ntohl (block->purpose.size);
176 if (bsize <
177 (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + sizeof (struct GNUNET_TIME_AbsoluteNBO)))
178 {
179 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
180 "Malformed block.");
181 lnc->status = GNUNET_SYSERR;
182 return;
183 }
170 esize = ntohl (block->purpose.size) 184 esize = ntohl (block->purpose.size)
171 - sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) 185 - sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose)
172 - sizeof (struct GNUNET_TIME_AbsoluteNBO); 186 - sizeof (struct GNUNET_TIME_AbsoluteNBO);
@@ -209,6 +223,7 @@ handle_lookup_block (void *cls,
209 223
210 lnc.request_id = ntohl (ln_msg->gns_header.r_id); 224 lnc.request_id = ntohl (ln_msg->gns_header.r_id);
211 lnc.nc = nc; 225 lnc.nc = nc;
226 lnc.status = GNUNET_OK;
212 if (GNUNET_SYSERR == 227 if (GNUNET_SYSERR ==
213 (ret = GSN_database->lookup_block (GSN_database->cls, 228 (ret = GSN_database->lookup_block (GSN_database->cls,
214 &ln_msg->query, 229 &ln_msg->query,
@@ -222,7 +237,7 @@ handle_lookup_block (void *cls,
222 GNUNET_SERVICE_client_drop (nc->client); 237 GNUNET_SERVICE_client_drop (nc->client);
223 return; 238 return;
224 } 239 }
225 if (0 == ret) 240 if ((0 == ret) || (GNUNET_SYSERR == lnc.status))
226 { 241 {
227 /* no records match at all, generate empty response */ 242 /* no records match at all, generate empty response */
228 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 243 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,