diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-03-26 14:28:27 +0100 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2021-03-26 14:28:27 +0100 |
commit | fa8b5926395406f96654aa5a0b84848dc4e1a519 (patch) | |
tree | 784111c575f181b7eff616a7a5d8ff7a41ea4394 /src/namestore | |
parent | 655fc47e417831125d6ebb5f68d4e86371cb931f (diff) | |
download | gnunet-fa8b5926395406f96654aa5a0b84848dc4e1a519.tar.gz gnunet-fa8b5926395406f96654aa5a0b84848dc4e1a519.zip |
-fixing memleaks and nptr derefs
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 16 | ||||
-rw-r--r-- | src/namestore/plugin_rest_namestore.c | 2 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index d6774b37b..79210939f 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -743,13 +743,14 @@ send_lookup_response (struct NamestoreClient *nc, | |||
743 | nick->flags = | 743 | nick->flags = |
744 | (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE; | 744 | (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE; |
745 | merge_with_nick_records (nick, rd_count, rd, &res_count, &res); | 745 | merge_with_nick_records (nick, rd_count, rd, &res_count, &res); |
746 | GNUNET_free (nick); | ||
747 | } | 746 | } |
748 | else | 747 | else |
749 | { | 748 | { |
750 | res_count = rd_count; | 749 | res_count = rd_count; |
751 | res = (struct GNUNET_GNSRECORD_Data *) rd; | 750 | res = (struct GNUNET_GNSRECORD_Data *) rd; |
752 | } | 751 | } |
752 | if (NULL != nick) | ||
753 | GNUNET_free (nick); | ||
753 | 754 | ||
754 | GNUNET_assert (-1 != GNUNET_GNSRECORD_records_get_size (res_count, res)); | 755 | GNUNET_assert (-1 != GNUNET_GNSRECORD_records_get_size (res_count, res)); |
755 | 756 | ||
@@ -758,12 +759,16 @@ send_lookup_response (struct NamestoreClient *nc, | |||
758 | rd_ser_len = GNUNET_GNSRECORD_records_get_size (res_count, res); | 759 | rd_ser_len = GNUNET_GNSRECORD_records_get_size (res_count, res); |
759 | if (rd_ser_len < 0) | 760 | if (rd_ser_len < 0) |
760 | { | 761 | { |
762 | if (rd != res) | ||
763 | GNUNET_free (res); | ||
761 | GNUNET_break (0); | 764 | GNUNET_break (0); |
762 | GNUNET_SERVICE_client_drop (nc->client); | 765 | GNUNET_SERVICE_client_drop (nc->client); |
763 | return; | 766 | return; |
764 | } | 767 | } |
765 | if (((size_t) rd_ser_len) >= UINT16_MAX - name_len - sizeof(*zir_msg)) | 768 | if (((size_t) rd_ser_len) >= UINT16_MAX - name_len - sizeof(*zir_msg)) |
766 | { | 769 | { |
770 | if (rd != res) | ||
771 | GNUNET_free (res); | ||
767 | GNUNET_break (0); | 772 | GNUNET_break (0); |
768 | GNUNET_SERVICE_client_drop (nc->client); | 773 | GNUNET_SERVICE_client_drop (nc->client); |
769 | return; | 774 | return; |
@@ -920,12 +925,15 @@ refresh_block (struct NamestoreClient *nc, | |||
920 | nick->flags = | 925 | nick->flags = |
921 | (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE; | 926 | (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ GNUNET_GNSRECORD_RF_PRIVATE; |
922 | merge_with_nick_records (nick, rd_count, rd, &res_count, &res); | 927 | merge_with_nick_records (nick, rd_count, rd, &res_count, &res); |
923 | GNUNET_free (nick); | ||
924 | } | 928 | } |
929 | if (NULL != nick) | ||
930 | GNUNET_free (nick); | ||
925 | if (0 == res_count) | 931 | if (0 == res_count) |
926 | { | 932 | { |
927 | if (NULL != nc) | 933 | if (NULL != nc) |
928 | send_store_response (nc, GNUNET_OK, rid); | 934 | send_store_response (nc, GNUNET_OK, rid); |
935 | if (rd != res) | ||
936 | GNUNET_free (res); | ||
929 | return; /* no data, no need to update cache */ | 937 | return; /* no data, no need to update cache */ |
930 | } | 938 | } |
931 | if (GNUNET_YES == disable_namecache) | 939 | if (GNUNET_YES == disable_namecache) |
@@ -936,6 +944,8 @@ refresh_block (struct NamestoreClient *nc, | |||
936 | GNUNET_NO); | 944 | GNUNET_NO); |
937 | if (NULL != nc) | 945 | if (NULL != nc) |
938 | send_store_response (nc, GNUNET_OK, rid); | 946 | send_store_response (nc, GNUNET_OK, rid); |
947 | if (rd != res) | ||
948 | GNUNET_free (res); | ||
939 | return; | 949 | return; |
940 | } | 950 | } |
941 | exp_time = GNUNET_GNSRECORD_record_get_expiration_time (res_count, res); | 951 | exp_time = GNUNET_GNSRECORD_record_get_expiration_time (res_count, res); |
@@ -970,6 +980,8 @@ refresh_block (struct NamestoreClient *nc, | |||
970 | &finish_cache_operation, | 980 | &finish_cache_operation, |
971 | cop); | 981 | cop); |
972 | GNUNET_free (block); | 982 | GNUNET_free (block); |
983 | if (rd != res) | ||
984 | GNUNET_free (res); | ||
973 | } | 985 | } |
974 | 986 | ||
975 | 987 | ||
diff --git a/src/namestore/plugin_rest_namestore.c b/src/namestore/plugin_rest_namestore.c index edcbeb874..ae93e5eff 100644 --- a/src/namestore/plugin_rest_namestore.c +++ b/src/namestore/plugin_rest_namestore.c | |||
@@ -375,6 +375,8 @@ get_egoentry_namestore (struct RequestHandle *handle, char *name) | |||
375 | if (NULL == name) | 375 | if (NULL == name) |
376 | return NULL; | 376 | return NULL; |
377 | tmp = strtok (copy, "/"); | 377 | tmp = strtok (copy, "/"); |
378 | if (NULL == tmp) | ||
379 | return NULL; | ||
378 | for (ego_entry = ego_head; NULL != ego_entry; | 380 | for (ego_entry = ego_head; NULL != ego_entry; |
379 | ego_entry = ego_entry->next) | 381 | ego_entry = ego_entry->next) |
380 | { | 382 | { |