From f619430fc962cc50f48e980841c76ca7fe1e801e Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Thu, 15 Mar 2012 13:54:04 +0000 Subject: [PATCH] -fixes --- src/gns/gns_api.c | 26 ++++++++++++++++--------- src/gns/gnunet-service-gns.c | 12 ++++++++---- src/gns/test_gns_dht_delegated_lookup.c | 2 ++ 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c index 1a268f952..26870cdfd 100644 --- a/src/gns/gns_api.c +++ b/src/gns/gns_api.c @@ -440,17 +440,25 @@ process_lookup_reply (struct GNUNET_GNS_QueueEntry *qe, len -= sizeof(struct GNUNET_GNS_ClientLookupResultMessage); - GNUNET_NAMESTORE_records_deserialize (len, (char*)&msg[1], - rd_count, - rd); - - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Received lookup reply from GNS service (count=%d)\n", - ntohl(msg->rd_count)); - GNUNET_CLIENT_receive (h->client, &process_message, h, GNUNET_TIME_UNIT_FOREVER_REL); - qe->lookup_proc(qe->proc_cls, rd_count, rd); + if (GNUNET_SYSERR == GNUNET_NAMESTORE_records_deserialize (len, + (char*)&msg[1], + rd_count, + rd)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to serialize lookup reply from GNS service!\n"); + qe->lookup_proc(qe->proc_cls, 0, NULL); + } + else + { + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Received lookup reply from GNS service (count=%d)\n", + ntohl(msg->rd_count)); + qe->lookup_proc(qe->proc_cls, rd_count, rd); + } } /** diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index bea63e2f7..aa3d3b3e8 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c @@ -633,6 +633,8 @@ handle_lookup(void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "LOOKUP"); size_t msg_size = 0; + size_t namelen; + char* name; struct ClientLookupHandle *clh; if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientLookupMessage)) @@ -655,15 +657,17 @@ handle_lookup(void *cls, GNUNET_SERVER_receive_done (client, GNUNET_OK); return; } - + + name = (char*)&sh_msg[1]; + namelen = strlen(name)+1; clh = GNUNET_malloc(sizeof(struct ClientLookupHandle)); clh->client = client; - clh->name = GNUNET_malloc(strlen((char*)&sh_msg[1]) + 1); - strcpy(clh->name, (char*)&sh_msg[1]); + clh->name = GNUNET_malloc(namelen); + strcpy(clh->name, name); clh->unique_id = sh_msg->id; clh->type = ntohl(sh_msg->type); - gns_resolver_lookup_record(zone_hash, clh->type, (char*)&sh_msg[1], + gns_resolver_lookup_record(zone_hash, clh->type, name, &send_lookup_response, clh); } diff --git a/src/gns/test_gns_dht_delegated_lookup.c b/src/gns/test_gns_dht_delegated_lookup.c index 4f3cd09a2..f81a8d028 100644 --- a/src/gns/test_gns_dht_delegated_lookup.c +++ b/src/gns/test_gns_dht_delegated_lookup.c @@ -313,6 +313,8 @@ do_lookup(void *cls, const struct GNUNET_PeerIdentity *id, alice_key = GNUNET_CRYPTO_rsa_key_create_from_file (alice_keyfile); bob_key = GNUNET_CRYPTO_rsa_key_create (); + + GNUNET_free(alice_keyfile); GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); GNUNET_CRYPTO_rsa_key_get_public (bob_key, &bob_pkey); -- 2.25.1