diff options
Diffstat (limited to 'src/namecache')
-rw-r--r-- | src/namecache/gnunet-service-namecache.c | 19 | ||||
-rw-r--r-- | src/namecache/namecache_api.c | 8 |
2 files changed, 22 insertions, 5 deletions
diff --git a/src/namecache/gnunet-service-namecache.c b/src/namecache/gnunet-service-namecache.c index cda1267e8..c852aaacc 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 | int 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, |
diff --git a/src/namecache/namecache_api.c b/src/namecache/namecache_api.c index 2bb233da1..2a60a2813 100644 --- a/src/namecache/namecache_api.c +++ b/src/namecache/namecache_api.c | |||
@@ -483,9 +483,11 @@ GNUNET_NAMECACHE_block_cache (struct GNUNET_NAMECACHE_Handle *h, | |||
483 | 483 | ||
484 | if (NULL == h->mq) | 484 | if (NULL == h->mq) |
485 | return NULL; | 485 | return NULL; |
486 | blen = ntohl (block->purpose.size) | 486 | blen = ntohl (block->purpose.size); |
487 | - sizeof (struct GNUNET_TIME_AbsoluteNBO) | 487 | GNUNET_assert (blen > (sizeof (struct GNUNET_TIME_AbsoluteNBO) + |
488 | - sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose); | 488 | sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose))); |
489 | blen -= (sizeof (struct GNUNET_TIME_AbsoluteNBO) + | ||
490 | sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose)); | ||
489 | rid = get_op_id (h); | 491 | rid = get_op_id (h); |
490 | qe = GNUNET_new (struct GNUNET_NAMECACHE_QueueEntry); | 492 | qe = GNUNET_new (struct GNUNET_NAMECACHE_QueueEntry); |
491 | qe->nsh = h; | 493 | qe->nsh = h; |