-fixes
authorMartin Schanzenbach <mschanzenbach@posteo.de>
Thu, 15 Mar 2012 13:54:04 +0000 (13:54 +0000)
committerMartin Schanzenbach <mschanzenbach@posteo.de>
Thu, 15 Mar 2012 13:54:04 +0000 (13:54 +0000)
src/gns/gns_api.c
src/gns/gnunet-service-gns.c
src/gns/test_gns_dht_delegated_lookup.c

index 1a268f952c1adbbcdef200f09f5c84480b56b7f6..26870cdfddf7302d53744720c7538c76063b415a 100644 (file)
@@ -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);
+  }
 }
 
 /**
index bea63e2f7dcf07c4af9e71d8d2066705fd5943f9..aa3d3b3e8ee8faa024291cb877d47d876c3d0dc2 100644 (file)
@@ -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);
 }
 
index 4f3cd09a275ea24637baf8889ef66cc9aa8247f8..f81a8d02830776e1f9b52640acfaf11cec5274ce 100644 (file)
@@ -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);