diff options
author | Carlo von lynX <lynX@time.to.get.psyced.org> | 2016-07-28 00:22:43 +0000 |
---|---|---|
committer | Carlo von lynX <lynX@time.to.get.psyced.org> | 2016-07-28 00:22:43 +0000 |
commit | 00da479663f9b8af36a89e6643fed03f4256ce28 (patch) | |
tree | 12156185c781a24ce5081700c1cd92de14a69cc2 /src/social | |
parent | 46b723ebd22301be02cfbca34c471f9397f163c5 (diff) | |
download | gnunet-00da479663f9b8af36a89e6643fed03f4256ce28.tar.gz gnunet-00da479663f9b8af36a89e6643fed03f4256ce28.zip |
social: leaks and untreated error conditions
Diffstat (limited to 'src/social')
-rw-r--r-- | src/social/gnunet-service-social.c | 26 | ||||
-rw-r--r-- | src/social/gnunet-social.c | 21 | ||||
-rw-r--r-- | src/social/social_api.c | 16 |
3 files changed, 43 insertions, 20 deletions
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, | |||
809 | if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD == ptype) | 809 | if (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD == ptype) |
810 | { | 810 | { |
811 | /* FIXME: last message was unfinished, cancel & remove from queue */ | 811 | /* FIXME: last message was unfinished, cancel & remove from queue */ |
812 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
813 | "FIXME: last message was unfinished.\n"); | ||
812 | } | 814 | } |
813 | 815 | ||
814 | tmit_msg = psyc_transmit_queue_message (&hst->plc, NULL, ntohs (pmsg->size), | 816 | tmit_msg = psyc_transmit_queue_message (&hst->plc, NULL, ntohs (pmsg->size), |
@@ -817,12 +819,14 @@ host_relay_message_part (struct Host *hst, | |||
817 | switch (ptype) | 819 | switch (ptype) |
818 | { | 820 | { |
819 | case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD: | 821 | case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD: |
820 | GNUNET_CONTAINER_multihashmap_put (hst->relay_msgs, &nym_pub_hash, tmit_msg, | 822 | GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_put |
821 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 823 | (hst->relay_msgs, &nym_pub_hash, tmit_msg, |
824 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | ||
822 | break; | 825 | break; |
823 | case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END: | 826 | case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END: |
824 | case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL: | 827 | case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL: |
825 | GNUNET_CONTAINER_multihashmap_remove (hst->relay_msgs, &nym_pub_hash, tmit_msg); | 828 | GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove |
829 | (hst->relay_msgs, &nym_pub_hash, tmit_msg)); | ||
826 | break; | 830 | break; |
827 | } | 831 | } |
828 | } | 832 | } |
@@ -985,17 +989,23 @@ place_recv_save_data (void *cls, | |||
985 | place_pub_str, DIR_SEPARATOR, | 989 | place_pub_str, DIR_SEPARATOR, |
986 | GNUNET_ntohll (msg->message_id)); | 990 | GNUNET_ntohll (msg->message_id)); |
987 | GNUNET_free (place_pub_str); | 991 | GNUNET_free (place_pub_str); |
988 | GNUNET_DISK_directory_create_for_file (filename); | 992 | if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (filename)) |
993 | { | ||
994 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "create", filename); | ||
995 | GNUNET_free (filename); | ||
996 | return; | ||
997 | } | ||
998 | |||
989 | struct GNUNET_DISK_FileHandle * | 999 | struct GNUNET_DISK_FileHandle * |
990 | fh = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_WRITE, | 1000 | fh = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_WRITE, |
991 | GNUNET_DISK_PERM_NONE); | 1001 | GNUNET_DISK_PERM_NONE); |
992 | if (NULL != fh) | 1002 | if (NULL != fh) |
993 | { | 1003 | { |
994 | if (plc->file_offset != GNUNET_DISK_file_seek | 1004 | if (plc->file_offset != GNUNET_DISK_file_seek |
995 | (fh, plc->file_offset, GNUNET_DISK_SEEK_SET)) { | 1005 | (fh, plc->file_offset, GNUNET_DISK_SEEK_SET)) { |
996 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "seek", filename); | 1006 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "seek", filename); |
997 | GNUNET_free (filename); | 1007 | GNUNET_free (filename); |
998 | return; | 1008 | return; |
999 | } | 1009 | } |
1000 | GNUNET_DISK_file_write (fh, data, data_size); | 1010 | GNUNET_DISK_file_write (fh, data, data_size); |
1001 | GNUNET_DISK_file_close (fh); | 1011 | 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, | |||
727 | return; | 727 | return; |
728 | } | 728 | } |
729 | 729 | ||
730 | struct GNUNET_PSYC_Message *join_msg = guest_enter_msg_create (); | ||
730 | gst = GNUNET_SOCIAL_guest_enter (app, ego, pub_key, | 731 | gst = GNUNET_SOCIAL_guest_enter (app, ego, pub_key, |
731 | GNUNET_PSYC_SLAVE_JOIN_NONE, | 732 | GNUNET_PSYC_SLAVE_JOIN_NONE, |
732 | peer, 0, NULL, guest_enter_msg_create (), | 733 | peer, 0, NULL, join_msg, slicer_create (), |
733 | slicer_create (), | ||
734 | guest_recv_local_enter, | 734 | guest_recv_local_enter, |
735 | guest_recv_entry_decision, NULL); | 735 | guest_recv_entry_decision, NULL); |
736 | GNUNET_free (join_msg); | ||
736 | plc = GNUNET_SOCIAL_guest_get_place (gst); | 737 | plc = GNUNET_SOCIAL_guest_get_place (gst); |
737 | } | 738 | } |
738 | 739 | ||
@@ -746,10 +747,12 @@ guest_enter_by_name (const char *gns_name) | |||
746 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 747 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
747 | "Entering to place by name as guest.\n"); | 748 | "Entering to place by name as guest.\n"); |
748 | 749 | ||
750 | struct GNUNET_PSYC_Message *join_msg = guest_enter_msg_create (); | ||
749 | gst = GNUNET_SOCIAL_guest_enter_by_name (app, ego, gns_name, NULL, | 751 | gst = GNUNET_SOCIAL_guest_enter_by_name (app, ego, gns_name, NULL, |
750 | guest_enter_msg_create (), slicer, | 752 | join_msg, slicer, |
751 | guest_recv_local_enter, | 753 | guest_recv_local_enter, |
752 | guest_recv_entry_decision, NULL); | 754 | guest_recv_entry_decision, NULL); |
755 | GNUNET_free (join_msg); | ||
753 | plc = GNUNET_SOCIAL_guest_get_place (gst); | 756 | plc = GNUNET_SOCIAL_guest_get_place (gst); |
754 | } | 757 | } |
755 | 758 | ||
@@ -1157,9 +1160,17 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
1157 | 1160 | ||
1158 | if (opt_ego) | 1161 | if (opt_ego) |
1159 | { | 1162 | { |
1160 | GNUNET_CRYPTO_ecdsa_public_key_from_string (opt_ego, | 1163 | if (GNUNET_OK != |
1164 | GNUNET_CRYPTO_ecdsa_public_key_from_string (opt_ego, | ||
1161 | strlen (opt_ego), | 1165 | strlen (opt_ego), |
1162 | &ego_pub_key); | 1166 | &ego_pub_key)) |
1167 | { | ||
1168 | FPRINTF (stderr, | ||
1169 | _("Public key `%s' malformed\n"), | ||
1170 | opt_ego); | ||
1171 | exit_fail (); | ||
1172 | return; | ||
1173 | } | ||
1163 | } | 1174 | } |
1164 | 1175 | ||
1165 | core = GNUNET_CORE_connect (cfg, NULL, &core_connected, NULL, NULL, | 1176 | 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, | |||
967 | 967 | ||
968 | if (GNUNET_YES == pmsg->is_host) | 968 | if (GNUNET_YES == pmsg->is_host) |
969 | { | 969 | { |
970 | struct GNUNET_SOCIAL_HostConnection *hconn = GNUNET_malloc (sizeof (*hconn)); | 970 | if (NULL != app->host_cb) { |
971 | hconn->app = app; | 971 | struct GNUNET_SOCIAL_HostConnection *hconn = GNUNET_malloc (sizeof (*hconn)); |
972 | hconn->plc_msg = *pmsg; | 972 | hconn->app = app; |
973 | if (NULL != app->host_cb) | 973 | hconn->plc_msg = *pmsg; |
974 | app->host_cb (app->cb_cls, hconn, ego, &pmsg->place_pub_key, pmsg->place_state); | 974 | app->host_cb (app->cb_cls, hconn, ego, &pmsg->place_pub_key, pmsg->place_state); |
975 | // FIXME: should this have a GNUNET_free (hconn) here? | ||
976 | } | ||
975 | } | 977 | } |
976 | else | 978 | else if (NULL != app->guest_cb) |
977 | { | 979 | { |
978 | struct GNUNET_SOCIAL_GuestConnection *gconn = GNUNET_malloc (sizeof (*gconn)); | 980 | struct GNUNET_SOCIAL_GuestConnection *gconn = GNUNET_malloc (sizeof (*gconn)); |
979 | gconn->app = app; | 981 | gconn->app = app; |
980 | gconn->plc_msg = *pmsg; | 982 | gconn->plc_msg = *pmsg; |
981 | if (NULL != app->guest_cb) | 983 | app->guest_cb (app->cb_cls, gconn, ego, &pmsg->place_pub_key, pmsg->place_state); |
982 | app->guest_cb (app->cb_cls, gconn, ego, &pmsg->place_pub_key, pmsg->place_state); | 984 | GNUNET_free (gconn); // FIXME: is this correct here? |
983 | } | 985 | } |
984 | } | 986 | } |
985 | 987 | ||