aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-09-27 11:37:46 +0000
committerChristian Grothoff <christian@grothoff.org>2012-09-27 11:37:46 +0000
commite1d237db3dc7d71e00844da8eb501896cf6d308f (patch)
treecbd0aabaa4a9a159f24fe4080b56d2885e897b34 /src/gns
parentda69908da5c89e01c663b54da76099033aca4bb0 (diff)
downloadgnunet-e1d237db3dc7d71e00844da8eb501896cf6d308f.tar.gz
gnunet-e1d237db3dc7d71e00844da8eb501896cf6d308f.zip
-fix leak
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/gnunet-service-gns_resolver.c102
1 files changed, 49 insertions, 53 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index d75d64f02..c6538aba0 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -211,6 +211,17 @@ is_canonical (const char* name)
211} 211}
212 212
213 213
214static void
215free_get_pseu_authority_handle (struct GetPseuAuthorityHandle *gph)
216{
217 gph->namestore_task = NULL;
218 GNUNET_free (gph->auth);
219 GNUNET_CRYPTO_rsa_key_free (gph->key);
220 GNUNET_CONTAINER_DLL_remove (gph_head, gph_tail, gph);
221 GNUNET_free (gph);
222}
223
224
214/** 225/**
215 * Callback that shortens authorities 226 * Callback that shortens authorities
216 * 227 *
@@ -233,11 +244,7 @@ create_pkey_cont (void* cls, int32_t success, const char* emsg)
233 //FIXME do sth with error 244 //FIXME do sth with error
234 struct GetPseuAuthorityHandle* gph = cls; 245 struct GetPseuAuthorityHandle* gph = cls;
235 246
236 gph->namestore_task = NULL; 247 free_get_pseu_authority_handle (gph);
237 GNUNET_free (gph->auth);
238 GNUNET_CRYPTO_rsa_key_free (gph->key);
239 GNUNET_CONTAINER_DLL_remove (gph_head, gph_tail, gph);
240 GNUNET_free (gph);
241} 248}
242 249
243 250
@@ -255,11 +262,11 @@ create_pkey_cont (void* cls, int32_t success, const char* emsg)
255 */ 262 */
256static void 263static void
257process_pseu_lookup_ns (void* cls, 264process_pseu_lookup_ns (void* cls,
258 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key, 265 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *key,
259 struct GNUNET_TIME_Absolute expiration, 266 struct GNUNET_TIME_Absolute expiration,
260 const char *name, unsigned int rd_count, 267 const char *name, unsigned int rd_count,
261 const struct GNUNET_NAMESTORE_RecordData *rd, 268 const struct GNUNET_NAMESTORE_RecordData *rd,
262 const struct GNUNET_CRYPTO_RsaSignature *signature) 269 const struct GNUNET_CRYPTO_RsaSignature *signature)
263{ 270{
264 struct GetPseuAuthorityHandle* gph = cls; 271 struct GetPseuAuthorityHandle* gph = cls;
265 struct GNUNET_NAMESTORE_RecordData new_pkey; 272 struct GNUNET_NAMESTORE_RecordData new_pkey;
@@ -269,10 +276,7 @@ process_pseu_lookup_ns (void* cls,
269 { 276 {
270 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 277 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
271 "GNS_AUTO_PSEU: Name %s already taken in NS!\n", name); 278 "GNS_AUTO_PSEU: Name %s already taken in NS!\n", name);
272 GNUNET_free (gph->auth); 279 free_get_pseu_authority_handle (gph);
273 GNUNET_CRYPTO_rsa_key_free (gph->key);
274 GNUNET_CONTAINER_DLL_remove (gph_head, gph_tail, gph);
275 GNUNET_free (gph);
276 return; 280 return;
277 } 281 }
278 282
@@ -288,11 +292,11 @@ process_pseu_lookup_ns (void* cls,
288 | GNUNET_NAMESTORE_RF_PRIVATE 292 | GNUNET_NAMESTORE_RF_PRIVATE
289 | GNUNET_NAMESTORE_RF_PENDING; 293 | GNUNET_NAMESTORE_RF_PENDING;
290 gph->namestore_task = GNUNET_NAMESTORE_record_create (namestore_handle, 294 gph->namestore_task = GNUNET_NAMESTORE_record_create (namestore_handle,
291 gph->key, 295 gph->key,
292 gph->test_name, 296 gph->test_name,
293 &new_pkey, 297 &new_pkey,
294 &create_pkey_cont, //cont 298 &create_pkey_cont,
295 gph); //cls 299 gph);
296} 300}
297 301
298/** 302/**
@@ -308,15 +312,11 @@ process_pseu_result (struct GetPseuAuthorityHandle* gph, char* name)
308 { 312 {
309 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 313 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
310 "GNS_AUTO_PSEU: No PSEU, no shorten. Finished.\n"); 314 "GNS_AUTO_PSEU: No PSEU, no shorten. Finished.\n");
311 GNUNET_free (gph->auth); 315 free_get_pseu_authority_handle (gph);
312 GNUNET_CRYPTO_rsa_key_free (gph->key);
313 GNUNET_CONTAINER_DLL_remove (gph_head, gph_tail, gph);
314 GNUNET_free (gph);
315 return; 316 return;
316 } 317 }
317 318
318 memcpy (gph->test_name, name, strlen(name)+1); 319 memcpy (gph->test_name, name, strlen(name) + 1);
319
320 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 320 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
321 "GNS_AUTO_PSEU: Checking %s for collision in NS\n", 321 "GNS_AUTO_PSEU: Checking %s for collision in NS\n",
322 gph->test_name); 322 gph->test_name);
@@ -324,13 +324,14 @@ process_pseu_result (struct GetPseuAuthorityHandle* gph, char* name)
324 * Check for collision 324 * Check for collision
325 */ 325 */
326 gph->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle, 326 gph->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle,
327 &gph->our_zone, 327 &gph->our_zone,
328 gph->test_name, 328 gph->test_name,
329 GNUNET_NAMESTORE_TYPE_ANY, 329 GNUNET_NAMESTORE_TYPE_ANY,
330 &process_pseu_lookup_ns, 330 &process_pseu_lookup_ns,
331 gph); 331 gph);
332} 332}
333 333
334
334/** 335/**
335 * Handle timeout for dht request 336 * Handle timeout for dht request
336 * 337 *
@@ -396,10 +397,7 @@ process_auth_discovery_dht_result (void* cls,
396 { 397 {
397 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 398 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
398 "GNS_GET_AUTH: got dht result null!\n", size); 399 "GNS_GET_AUTH: got dht result null!\n", size);
399 GNUNET_free (gph->auth); 400 free_get_pseu_authority_handle (gph);
400 GNUNET_CRYPTO_rsa_key_free (gph->key);
401 GNUNET_CONTAINER_DLL_remove (gph_head, gph_tail, gph);
402 GNUNET_free (gph);
403 return; 401 return;
404 } 402 }
405 403
@@ -545,12 +543,9 @@ process_zone_to_name_discover (void *cls,
545 return; 543 return;
546 } 544 }
547 /* we found a match in our own zone */ 545 /* we found a match in our own zone */
548 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 546 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
549 "GNS_AUTO_PSEU: name for zone in our root %s\n", name); 547 "GNS_AUTO_PSEU: name for zone in our root %s\n", name);
550 GNUNET_free (gph->auth); 548 free_get_pseu_authority_handle (gph);
551 GNUNET_CRYPTO_rsa_key_free (gph->key);
552 GNUNET_CONTAINER_DLL_remove (gph_head, gph_tail, gph);
553 GNUNET_free (gph);
554} 549}
555 550
556 551
@@ -591,10 +586,9 @@ start_shorten (struct AuthorityChain *auth,
591 "Failed to encode RSA key on shorten\n"); 586 "Failed to encode RSA key on shorten\n");
592 return; 587 return;
593 } 588 }
594
595 gph = GNUNET_malloc (sizeof (struct GetPseuAuthorityHandle)); 589 gph = GNUNET_malloc (sizeof (struct GetPseuAuthorityHandle));
596 gph->key = GNUNET_CRYPTO_rsa_decode_key ((const char*) pb_key, ntohs (pb_key->len)); 590 gph->key = GNUNET_CRYPTO_rsa_decode_key ((const char*) pb_key, ntohs (pb_key->len));
597 591 GNUNET_free (pb_key);
598 if (NULL == gph->key) 592 if (NULL == gph->key)
599 { 593 {
600 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 594 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -792,6 +786,8 @@ finish_shorten (struct ResolverHandle *rh,
792static void 786static void
793finish_get_auth (struct ResolverHandle *rh, 787finish_get_auth (struct ResolverHandle *rh,
794 struct GetNameAuthorityHandle* rlh); 788 struct GetNameAuthorityHandle* rlh);
789
790
795/** 791/**
796 * Shutdown resolver 792 * Shutdown resolver
797 */ 793 */
@@ -801,24 +797,24 @@ gns_resolver_cleanup ()
801 unsigned int s; 797 unsigned int s;
802 struct GetPseuAuthorityHandle *tmp; 798 struct GetPseuAuthorityHandle *tmp;
803 799
804 800 while (NULL != (tmp = gph_head))
805 tmp = gph_head;
806 for (tmp = gph_head; tmp != NULL; tmp = gph_head)
807 { 801 {
808 if (tmp->get_handle != NULL) 802 if (tmp->get_handle != NULL)
803 {
809 GNUNET_DHT_get_stop (tmp->get_handle); 804 GNUNET_DHT_get_stop (tmp->get_handle);
810 tmp->get_handle = NULL; 805 tmp->get_handle = NULL;
806 }
811 if (tmp->timeout != GNUNET_SCHEDULER_NO_TASK) 807 if (tmp->timeout != GNUNET_SCHEDULER_NO_TASK)
808 {
812 GNUNET_SCHEDULER_cancel (tmp->timeout); 809 GNUNET_SCHEDULER_cancel (tmp->timeout);
813 tmp->timeout = GNUNET_SCHEDULER_NO_TASK; 810 tmp->timeout = GNUNET_SCHEDULER_NO_TASK;
814 811 }
815 if (NULL != tmp->namestore_task) 812 if (NULL != tmp->namestore_task)
813 {
816 GNUNET_NAMESTORE_cancel (tmp->namestore_task); 814 GNUNET_NAMESTORE_cancel (tmp->namestore_task);
817 tmp->namestore_task = NULL; 815 tmp->namestore_task = NULL;
818 GNUNET_free (tmp->auth); 816 }
819 GNUNET_CRYPTO_rsa_key_free (tmp->key); 817 free_get_pseu_authority_handle (tmp);
820 GNUNET_CONTAINER_DLL_remove (gph_head, gph_tail, tmp);
821 GNUNET_free (tmp);
822 } 818 }
823 819
824 while (NULL != rlh_head) 820 while (NULL != rlh_head)