gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r37596 - gnunet/src/social


From: gnunet
Subject: [GNUnet-SVN] r37596 - gnunet/src/social
Date: Thu, 28 Jul 2016 02:22:44 +0200

Author: lynx
Date: 2016-07-28 02:22:43 +0200 (Thu, 28 Jul 2016)
New Revision: 37596

Modified:
   gnunet/src/social/gnunet-service-social.c
   gnunet/src/social/gnunet-social.c
   gnunet/src/social/social_api.c
Log:
social: leaks and untreated error conditions

Modified: gnunet/src/social/gnunet-service-social.c
===================================================================
--- gnunet/src/social/gnunet-service-social.c   2016-07-27 23:15:28 UTC (rev 
37595)
+++ gnunet/src/social/gnunet-service-social.c   2016-07-28 00:22:43 UTC (rev 
37596)
@@ -809,6 +809,8 @@
   if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD == ptype)
   {
     /* FIXME: last message was unfinished, cancel & remove from queue */
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+               "FIXME: last message was unfinished.\n");
   }
 
   tmit_msg = psyc_transmit_queue_message (&hst->plc, NULL, ntohs (pmsg->size),
@@ -817,12 +819,14 @@
   switch (ptype)
   {
   case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD:
-    GNUNET_CONTAINER_multihashmap_put (hst->relay_msgs, &nym_pub_hash, 
tmit_msg,
-                                       
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+    GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_put
+                                     (hst->relay_msgs, &nym_pub_hash, tmit_msg,
+                                       
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
     break;
   case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END:
   case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL:
-    GNUNET_CONTAINER_multihashmap_remove (hst->relay_msgs, &nym_pub_hash, 
tmit_msg);
+    GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove
+                                    (hst->relay_msgs, &nym_pub_hash, 
tmit_msg));
     break;
   }
 }
@@ -985,7 +989,13 @@
                    place_pub_str, DIR_SEPARATOR,
                    GNUNET_ntohll (msg->message_id));
   GNUNET_free (place_pub_str);
-  GNUNET_DISK_directory_create_for_file (filename);
+  if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (filename))
+  {
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "create", filename);
+    GNUNET_free (filename);
+    return;
+  }
+
   struct GNUNET_DISK_FileHandle *
     fh = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_WRITE,
                                 GNUNET_DISK_PERM_NONE);
@@ -992,10 +1002,10 @@
   if (NULL != fh)
   {
     if (plc->file_offset != GNUNET_DISK_file_seek
-         (fh, plc->file_offset, GNUNET_DISK_SEEK_SET)) {
-        GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "seek", filename);
-       GNUNET_free (filename);
-       return;
+                           (fh, plc->file_offset, GNUNET_DISK_SEEK_SET)) {
+      GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "seek", filename);
+      GNUNET_free (filename);
+      return;
     }
     GNUNET_DISK_file_write (fh, data, data_size);
     GNUNET_DISK_file_close (fh);

Modified: gnunet/src/social/gnunet-social.c
===================================================================
--- gnunet/src/social/gnunet-social.c   2016-07-27 23:15:28 UTC (rev 37595)
+++ gnunet/src/social/gnunet-social.c   2016-07-28 00:22:43 UTC (rev 37596)
@@ -727,12 +727,13 @@
     return;
   }
 
+  struct GNUNET_PSYC_Message *join_msg = guest_enter_msg_create ();
   gst = GNUNET_SOCIAL_guest_enter (app, ego, pub_key,
                                    GNUNET_PSYC_SLAVE_JOIN_NONE,
-                                   peer, 0, NULL, guest_enter_msg_create (),
-                                   slicer_create (),
+                                   peer, 0, NULL, join_msg, slicer_create (),
                                    guest_recv_local_enter,
                                    guest_recv_entry_decision, NULL);
+  GNUNET_free (join_msg);
   plc = GNUNET_SOCIAL_guest_get_place (gst);
 }
 
@@ -746,10 +747,12 @@
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Entering to place by name as guest.\n");
 
+  struct GNUNET_PSYC_Message *join_msg = guest_enter_msg_create ();
   gst = GNUNET_SOCIAL_guest_enter_by_name (app, ego, gns_name, NULL,
-                                           guest_enter_msg_create (), slicer,
+                                           join_msg, slicer,
                                            guest_recv_local_enter,
                                            guest_recv_entry_decision, NULL);
+  GNUNET_free (join_msg);
   plc = GNUNET_SOCIAL_guest_get_place (gst);
 }
 
@@ -1157,9 +1160,17 @@
 
   if (opt_ego)
   {
-    GNUNET_CRYPTO_ecdsa_public_key_from_string (opt_ego,
+    if (GNUNET_OK !=
+        GNUNET_CRYPTO_ecdsa_public_key_from_string (opt_ego,
                                                 strlen (opt_ego),
-                                                &ego_pub_key);
+                                                &ego_pub_key))
+    {
+      FPRINTF (stderr,
+               _("Public key `%s' malformed\n"),
+               opt_ego);
+      exit_fail ();
+      return;
+    }
   }
 
   core = GNUNET_CORE_connect (cfg, NULL, &core_connected, NULL, NULL,

Modified: gnunet/src/social/social_api.c
===================================================================
--- gnunet/src/social/social_api.c      2016-07-27 23:15:28 UTC (rev 37595)
+++ gnunet/src/social/social_api.c      2016-07-28 00:22:43 UTC (rev 37596)
@@ -967,19 +967,21 @@
 
   if (GNUNET_YES == pmsg->is_host)
   {
-    struct GNUNET_SOCIAL_HostConnection *hconn = GNUNET_malloc (sizeof 
(*hconn));
-    hconn->app = app;
-    hconn->plc_msg = *pmsg;
-    if (NULL != app->host_cb)
+    if (NULL != app->host_cb) {
+      struct GNUNET_SOCIAL_HostConnection *hconn = GNUNET_malloc (sizeof 
(*hconn));
+      hconn->app = app;
+      hconn->plc_msg = *pmsg;
       app->host_cb (app->cb_cls, hconn, ego, &pmsg->place_pub_key, 
pmsg->place_state);
+      // FIXME: should this have a GNUNET_free (hconn) here?
+    }
   }
-  else
+  else if (NULL != app->guest_cb)
   {
     struct GNUNET_SOCIAL_GuestConnection *gconn = GNUNET_malloc (sizeof 
(*gconn));
     gconn->app = app;
     gconn->plc_msg = *pmsg;
-    if (NULL != app->guest_cb)
-      app->guest_cb (app->cb_cls, gconn, ego, &pmsg->place_pub_key, 
pmsg->place_state);
+    app->guest_cb (app->cb_cls, gconn, ego, &pmsg->place_pub_key, 
pmsg->place_state);
+    GNUNET_free (gconn); // FIXME: is this correct here?
   }
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]