From: Carlo von lynX Date: Thu, 28 Jul 2016 00:22:43 +0000 (+0000) Subject: social: leaks and untreated error conditions X-Git-Tag: initial-import-from-subversion-38251~486 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=00da479663f9b8af36a89e6643fed03f4256ce28;p=oweals%2Fgnunet.git social: leaks and untreated error conditions --- diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index eca1b14d7..e499130d4 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c @@ -809,6 +809,8 @@ host_relay_message_part (struct Host *hst, 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 @@ host_relay_message_part (struct Host *hst, 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,17 +989,23 @@ place_recv_save_data (void *cls, 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); 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); diff --git a/src/social/gnunet-social.c b/src/social/gnunet-social.c index 68a45bd5e..ab08c90f8 100644 --- a/src/social/gnunet-social.c +++ b/src/social/gnunet-social.c @@ -727,12 +727,13 @@ guest_enter (const struct GNUNET_CRYPTO_EddsaPublicKey *pub_key, 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 @@ guest_enter_by_name (const char *gns_name) 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 @@ run (void *cls, char *const *args, const char *cfgfile, 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, diff --git a/src/social/social_api.c b/src/social/social_api.c index c33f39dce..a7a4e9dcf 100644 --- a/src/social/social_api.c +++ b/src/social/social_api.c @@ -967,19 +967,21 @@ app_recv_place (void *cls, 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? } }