- fix use of uninitialized memory
[oweals/gnunet.git] / src / peerinfo-tool / gnunet-peerinfo.c
index 05ae99e8d35a5b763d0d493d3b7ee717dad7d773..53c2293d8a8e326b91f30678c6eb8ff526eca764 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001-2014 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2001-2014 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -14,8 +14,8 @@
 
      You should have received a copy of the GNU General Public License
      along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
+     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+     Boston, MA 02110-1301, USA.
 */
 
 /**
@@ -291,15 +291,19 @@ process_resolved_address (void *cls,
 
   if (NULL != address)
   {
-    if (NULL == ar->result)
+    if (0 != strlen (address))
+    {
+      if (NULL != ar->result)
+        GNUNET_free (ar->result);
       ar->result = GNUNET_strdup (address);
+    }
     return;
   }
   ar->atsc = NULL;
   if (GNUNET_SYSERR == res)
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-             _("Failure: Cannot convert address to string for peer `%s'\n"),
-             GNUNET_i2s (&ar->pc->peer));
+                _("Failure: Cannot convert address to string for peer `%s'\n"),
+                GNUNET_i2s (&ar->pc->peer));
   pc->num_addresses++;
   if (pc->num_addresses == pc->address_list_size)
     dump_pc (pc);
@@ -346,6 +350,11 @@ print_address (void *cls,
   ar = &pc->address_list[--pc->off];
   ar->pc = pc;
   ar->expiration = expiration;
+  GNUNET_asprintf (&ar->result,
+                   "%s:%u:%u",
+                   address->transport_name,
+                   address->address_length,
+                   address->local_info);
   ar->atsc = GNUNET_TRANSPORT_address_to_string (cfg,
                                                  address,
                                                  no_resolve,