gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: -fixing memleaks and nptr derefs


From: gnunet
Subject: [gnunet] branch master updated: -fixing memleaks and nptr derefs
Date: Fri, 26 Mar 2021 14:30:13 +0100

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new fa8b59263 -fixing memleaks and nptr derefs
fa8b59263 is described below

commit fa8b5926395406f96654aa5a0b84848dc4e1a519
Author: Martin Schanzenbach <mschanzenbach@posteo.de>
AuthorDate: Fri Mar 26 14:28:27 2021 +0100

    -fixing memleaks and nptr derefs
---
 src/cadet/gnunet-service-cadet_channel.c |  1 +
 src/gnsrecord/gnsrecord_misc.c           | 15 ++++++++++-----
 src/namestore/gnunet-service-namestore.c | 16 ++++++++++++++--
 src/namestore/plugin_rest_namestore.c    |  2 ++
 src/util/configuration.c                 |  1 +
 src/util/container_meta_data.c           |  7 +++++--
 src/util/crypto_rsa.c                    |  1 +
 src/util/os_installation.c               |  5 +++++
 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,
     }
     else
     {
+      GNUNET_free (env);
       GNUNET_break (0);
       return GNUNET_SYSERR;
     }
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
                                      size_t *data_size,
                                      uint32_t *type)
 {
+  char *tmp;
   *type = ntohl (key->type);
   *data_size = GNUNET_IDENTITY_key_get_length (key);
   if (0 == *data_size)
     return GNUNET_SYSERR;
-  *data = GNUNET_malloc (*data_size);
-  return (GNUNET_IDENTITY_write_key_to_buffer (key, *data, *data_size) ==
-          *data_size?
-          GNUNET_OK :
-          GNUNET_SYSERR);
+  tmp = GNUNET_malloc (*data_size);
+  if (GNUNET_IDENTITY_write_key_to_buffer (key, tmp, *data_size)
+      != *data_size) {
+    GNUNET_free (tmp);
+    *data_size = 0;
+    return GNUNET_SYSERR;
+  }
+  *data = tmp;
+  return GNUNET_OK;
 }
 
 
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,
     nick->flags =
       (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ 
GNUNET_GNSRECORD_RF_PRIVATE;
     merge_with_nick_records (nick, rd_count, rd, &res_count, &res);
-    GNUNET_free (nick);
   }
   else
   {
     res_count = rd_count;
     res = (struct GNUNET_GNSRECORD_Data *) rd;
   }
+  if (NULL != nick)
+    GNUNET_free (nick);
 
   GNUNET_assert (-1 != GNUNET_GNSRECORD_records_get_size (res_count, res));
 
@@ -758,12 +759,16 @@ send_lookup_response (struct NamestoreClient *nc,
   rd_ser_len = GNUNET_GNSRECORD_records_get_size (res_count, res);
   if (rd_ser_len < 0)
   {
+    if (rd != res)
+      GNUNET_free (res);
     GNUNET_break (0);
     GNUNET_SERVICE_client_drop (nc->client);
     return;
   }
   if (((size_t) rd_ser_len) >= UINT16_MAX - name_len - sizeof(*zir_msg))
   {
+    if (rd != res)
+      GNUNET_free (res);
     GNUNET_break (0);
     GNUNET_SERVICE_client_drop (nc->client);
     return;
@@ -920,12 +925,15 @@ refresh_block (struct NamestoreClient *nc,
     nick->flags =
       (nick->flags | GNUNET_GNSRECORD_RF_PRIVATE) ^ 
GNUNET_GNSRECORD_RF_PRIVATE;
     merge_with_nick_records (nick, rd_count, rd, &res_count, &res);
-    GNUNET_free (nick);
   }
+  if (NULL != nick)
+    GNUNET_free (nick);
   if (0 == res_count)
   {
     if (NULL != nc)
       send_store_response (nc, GNUNET_OK, rid);
+    if (rd != res)
+      GNUNET_free (res);
     return;   /* no data, no need to update cache */
   }
   if (GNUNET_YES == disable_namecache)
@@ -936,6 +944,8 @@ refresh_block (struct NamestoreClient *nc,
                               GNUNET_NO);
     if (NULL != nc)
       send_store_response (nc, GNUNET_OK, rid);
+    if (rd != res)
+      GNUNET_free (res);
     return;
   }
   exp_time = GNUNET_GNSRECORD_record_get_expiration_time (res_count, res);
@@ -970,6 +980,8 @@ refresh_block (struct NamestoreClient *nc,
                                           &finish_cache_operation,
                                           cop);
   GNUNET_free (block);
+  if (rd != res)
+    GNUNET_free (res);
 }
 
 
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)
   if (NULL == name)
     return NULL;
   tmp = strtok (copy, "/");
+  if (NULL == tmp)
+    return NULL;
   for (ego_entry = ego_head; NULL != ego_entry;
        ego_entry = ego_entry->next)
   {
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,
     if (NULL == h)
     {
       GNUNET_free (fn);
+      GNUNET_free (cfg_buf);
       return GNUNET_SYSERR;
     }
     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
     {
       /* does not fit! */
       GNUNET_free (ent);
+      if (NULL != cdata)
+        GNUNET_free (cdata);
+      cdata = NULL;
       return GNUNET_SYSERR;
     }
 
@@ -976,9 +979,9 @@ GNUNET_CONTAINER_meta_data_serialize (const struct 
GNUNET_CONTAINER_MetaData
     if (NULL != pos->mime_type)
       left -= strlen (pos->mime_type) + 1;
 
-    GNUNET_free (cdata);
+    if (NULL != cdata)
+      GNUNET_free (cdata);
     cdata = NULL;
-
     i++;
   }
   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,
          __FILE__,
          __LINE__,
          gcry_strerror (rc));
+    gcry_sexp_release (data);
     GNUNET_break (0);
     return NULL;
   }
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,
                                            "SUID_BINARY_PATH",
                                            &path);
   if ((NULL == path) || (0 == strlen (path)))
+  {
+    if (NULL != path)
+      GNUNET_free (path);
+    cache = NULL;
     return GNUNET_OS_get_libexec_binary_path (progname);
+  }
   path_len = strlen (path);
   GNUNET_asprintf (&binary,
                    "%s%s%s",

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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