aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2021-03-26 14:28:27 +0100
committerMartin Schanzenbach <mschanzenbach@posteo.de>2021-03-26 14:28:27 +0100
commitfa8b5926395406f96654aa5a0b84848dc4e1a519 (patch)
tree784111c575f181b7eff616a7a5d8ff7a41ea4394
parent655fc47e417831125d6ebb5f68d4e86371cb931f (diff)
downloadgnunet-fa8b5926395406f96654aa5a0b84848dc4e1a519.tar.gz
gnunet-fa8b5926395406f96654aa5a0b84848dc4e1a519.zip
-fixing memleaks and nptr derefs
-rw-r--r--src/cadet/gnunet-service-cadet_channel.c1
-rw-r--r--src/gnsrecord/gnsrecord_misc.c15
-rw-r--r--src/namestore/gnunet-service-namestore.c16
-rw-r--r--src/namestore/plugin_rest_namestore.c2
-rw-r--r--src/util/configuration.c1
-rw-r--r--src/util/container_meta_data.c7
-rw-r--r--src/util/crypto_rsa.c1
-rw-r--r--src/util/os_installation.c5
8 files changed, 39 insertions, 9 deletions
diff --git a/src/cadet/gnunet-service-cadet_channel.c b/src/cadet/gnunet-service-cadet_channel.c
index 6b22ae2b4..ae5d9210f 100644
--- a/src/cadet/gnunet-service-cadet_channel.c
+++ b/src/cadet/gnunet-service-cadet_channel.c
@@ -1858,6 +1858,7 @@ GCCH_handle_local_data (struct CadetChannel *ch,
1858 } 1858 }
1859 else 1859 else
1860 { 1860 {
1861 GNUNET_free (env);
1861 GNUNET_break (0); 1862 GNUNET_break (0);
1862 return GNUNET_SYSERR; 1863 return GNUNET_SYSERR;
1863 } 1864 }
diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c
index dacd7ca31..b907eed27 100644
--- a/src/gnsrecord/gnsrecord_misc.c
+++ b/src/gnsrecord/gnsrecord_misc.c
@@ -296,15 +296,20 @@ GNUNET_GNSRECORD_data_from_identity (const struct
296 size_t *data_size, 296 size_t *data_size,
297 uint32_t *type) 297 uint32_t *type)
298{ 298{
299 char *tmp;
299 *type = ntohl (key->type); 300 *type = ntohl (key->type);
300 *data_size = GNUNET_IDENTITY_key_get_length (key); 301 *data_size = GNUNET_IDENTITY_key_get_length (key);
301 if (0 == *data_size) 302 if (0 == *data_size)
302 return GNUNET_SYSERR; 303 return GNUNET_SYSERR;
303 *data = GNUNET_malloc (*data_size); 304 tmp = GNUNET_malloc (*data_size);
304 return (GNUNET_IDENTITY_write_key_to_buffer (key, *data, *data_size) == 305 if (GNUNET_IDENTITY_write_key_to_buffer (key, tmp, *data_size)
305 *data_size? 306 != *data_size) {
306 GNUNET_OK : 307 GNUNET_free (tmp);
307 GNUNET_SYSERR); 308 *data_size = 0;
309 return GNUNET_SYSERR;
310 }
311 *data = tmp;
312 return GNUNET_OK;
308} 313}
309 314
310 315
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 {
diff --git a/src/util/configuration.c b/src/util/configuration.c
index bda643b83..3294d11f4 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -606,6 +606,7 @@ GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg,
606 if (NULL == h) 606 if (NULL == h)
607 { 607 {
608 GNUNET_free (fn); 608 GNUNET_free (fn);
609 GNUNET_free (cfg_buf);
609 return GNUNET_SYSERR; 610 return GNUNET_SYSERR;
610 } 611 }
611 if (((ssize_t) size) != 612 if (((ssize_t) size) !=
diff --git a/src/util/container_meta_data.c b/src/util/container_meta_data.c
index b66a7b258..efaac1136 100644
--- a/src/util/container_meta_data.c
+++ b/src/util/container_meta_data.c
@@ -964,6 +964,9 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
964 { 964 {
965 /* does not fit! */ 965 /* does not fit! */
966 GNUNET_free (ent); 966 GNUNET_free (ent);
967 if (NULL != cdata)
968 GNUNET_free (cdata);
969 cdata = NULL;
967 return GNUNET_SYSERR; 970 return GNUNET_SYSERR;
968 } 971 }
969 972
@@ -976,9 +979,9 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
976 if (NULL != pos->mime_type) 979 if (NULL != pos->mime_type)
977 left -= strlen (pos->mime_type) + 1; 980 left -= strlen (pos->mime_type) + 1;
978 981
979 GNUNET_free (cdata); 982 if (NULL != cdata)
983 GNUNET_free (cdata);
980 cdata = NULL; 984 cdata = NULL;
981
982 i++; 985 i++;
983 } 986 }
984 GNUNET_free (ent); 987 GNUNET_free (ent);
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c
index 63232cab6..5e4c4d1e6 100644
--- a/src/util/crypto_rsa.c
+++ b/src/util/crypto_rsa.c
@@ -863,6 +863,7 @@ rsa_sign_mpi (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
863 __FILE__, 863 __FILE__,
864 __LINE__, 864 __LINE__,
865 gcry_strerror (rc)); 865 gcry_strerror (rc));
866 gcry_sexp_release (data);
866 GNUNET_break (0); 867 GNUNET_break (0);
867 return NULL; 868 return NULL;
868 } 869 }
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
index d1e5e0da5..02d4d439d 100644
--- a/src/util/os_installation.c
+++ b/src/util/os_installation.c
@@ -736,7 +736,12 @@ GNUNET_OS_get_suid_binary_path (const struct GNUNET_CONFIGURATION_Handle *cfg,
736 "SUID_BINARY_PATH", 736 "SUID_BINARY_PATH",
737 &path); 737 &path);
738 if ((NULL == path) || (0 == strlen (path))) 738 if ((NULL == path) || (0 == strlen (path)))
739 {
740 if (NULL != path)
741 GNUNET_free (path);
742 cache = NULL;
739 return GNUNET_OS_get_libexec_binary_path (progname); 743 return GNUNET_OS_get_libexec_binary_path (progname);
744 }
740 path_len = strlen (path); 745 path_len = strlen (path);
741 GNUNET_asprintf (&binary, 746 GNUNET_asprintf (&binary,
742 "%s%s%s", 747 "%s%s%s",