gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: - address coverity findings !coverity


From: gnunet
Subject: [gnunet] branch master updated: - address coverity findings !coverity
Date: Tue, 25 Oct 2022 08:03:50 +0200

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 3ae41c686 - address coverity findings !coverity
     new fa48dbb24 Merge branch 'master' of git+ssh://git.gnunet.org/gnunet
3ae41c686 is described below

commit 3ae41c6868db101c0b7d5cabc0776a376654bf5d
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Tue Oct 25 15:03:01 2022 +0900

    - address coverity findings !coverity
---
 src/datastore/plugin_datastore_sqlite.c    | 1 +
 src/gns/gnunet-bcd.c                       | 8 ++++----
 src/namestore/gnunet-namestore-zonefile.c  | 8 +++++---
 src/namestore/gnunet-namestore.c           | 4 +---
 src/namestore/gnunet-service-namestore.c   | 5 +++++
 src/reclaim/plugin_rest_reclaim.c          | 4 ++--
 src/revocation/gnunet-revocation-tvg.c     | 5 ++++-
 src/util/client.c                          | 6 +++---
 src/util/crypto_hash.c                     | 3 ++-
 src/util/gnunet-crypto-tvg.c               | 5 +++++
 src/zonemaster/gnunet-service-zonemaster.c | 6 ++++--
 11 files changed, 36 insertions(+), 19 deletions(-)

diff --git a/src/datastore/plugin_datastore_sqlite.c 
b/src/datastore/plugin_datastore_sqlite.c
index 3c2d7f2d4..5ea9da4cb 100644
--- a/src/datastore/plugin_datastore_sqlite.c
+++ b/src/datastore/plugin_datastore_sqlite.c
@@ -253,6 +253,7 @@ create_indices (sqlite3 *dbh)
   {                                                  \
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", e); \
     sqlite3_free (e);                                \
+    e = NULL;                                        \
   }
 #endif
 
diff --git a/src/gns/gnunet-bcd.c b/src/gns/gnunet-bcd.c
index 60fe25945..754f8ac6f 100644
--- a/src/gns/gnunet-bcd.c
+++ b/src/gns/gnunet-bcd.c
@@ -484,14 +484,14 @@ create_response (void *cls,
                                internal_error->response);
   }
 
-  MHD_add_response_header (pdfrs,
+  GNUNET_assert (MHD_NO != MHD_add_response_header (pdfrs,
                            MHD_HTTP_HEADER_CONTENT_TYPE,
-                           (NULL == qrpng) ? "application/pdf" : "image/png");
-  MHD_add_response_header (pdfrs,
+                           (NULL == qrpng) ? "application/pdf" : "image/png"));
+  GNUNET_assert (MHD_NO != MHD_add_response_header (pdfrs,
                            MHD_HTTP_HEADER_CONTENT_DISPOSITION,
                            (NULL == qrpng) ?
                            "attachment; filename=\"gns-business-card.pdf\"" :
-                           "attachment; filename=\"gns-qr-code.png\"");
+                           "attachment; filename=\"gns-qr-code.png\""));
   MHD_RESULT r = MHD_queue_response (connection, MHD_HTTP_OK, pdfrs);
 
   MHD_destroy_response (pdfrs);
diff --git a/src/namestore/gnunet-namestore-zonefile.c 
b/src/namestore/gnunet-namestore-zonefile.c
index ff3b2a565..8820dcdfa 100644
--- a/src/namestore/gnunet-namestore-zonefile.c
+++ b/src/namestore/gnunet-namestore-zonefile.c
@@ -405,7 +405,9 @@ parse (void *cls)
       if (NULL == next)
       {
         fprintf (stderr, "Error at line %u: %s\n", ln, token);
-        break;
+        ret = 1;
+        GNUNET_SCHEDULER_shutdown ();
+        return;
       }
       next[0] = '\0';
       next++;
@@ -493,7 +495,7 @@ parse (void *cls)
       {
         if (GNUNET_SYSERR == parse_ttl (token, &ttl))
         {
-          fprintf (stderr, _("Failed to parse $TTL\n"));
+          fprintf (stderr, _ ("Failed to parse $TTL\n"));
           ret = 1;
           GNUNET_SCHEDULER_shutdown ();
           return;
@@ -504,7 +506,7 @@ parse (void *cls)
       {
         if (GNUNET_SYSERR == parse_origin (token, origin))
         {
-          fprintf (stderr, _("Failed to parse $ORIGIN from %s\n"), token);
+          fprintf (stderr, _ ("Failed to parse $ORIGIN from %s\n"), token);
           ret = 1;
           GNUNET_SCHEDULER_shutdown ();
           return;
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index f6e53a340..d6154f0aa 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -614,7 +614,6 @@ display_record (const struct GNUNET_IDENTITY_PrivateKey 
*zone_key,
   const char *typestr;
   char *s;
   const char *ets;
-  struct GNUNET_IDENTITY_PublicKey pk;
   struct GNUNET_TIME_Absolute at;
   struct GNUNET_TIME_Relative rt;
   struct EgoEntry *ego;
@@ -651,8 +650,7 @@ display_record (const struct GNUNET_IDENTITY_PrivateKey 
*zone_key,
     return;
   if (! list_orphaned && is_orphaned)
     return;
-  GNUNET_IDENTITY_key_get_public (zone_key, &pk);
-  orphaned_str = GNUNET_IDENTITY_public_key_to_string (&pk);
+  orphaned_str = GNUNET_IDENTITY_private_key_to_string (zone_key);
   fprintf (stdout, "%s.%s:\n", rname, is_orphaned ? orphaned_str :
            ego->identifier);
   GNUNET_free (orphaned_str);
diff --git a/src/namestore/gnunet-service-namestore.c 
b/src/namestore/gnunet-service-namestore.c
index b3c077141..92c81c4eb 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -752,7 +752,11 @@ send_lookup_response_with_filter (struct NamestoreClient 
*nc,
     GNUNET_free (nick);
 
   if (0 == res_count)
+  {
+    if (rd_nf != res)
+      GNUNET_free (res);
     return 0;
+  }
   GNUNET_assert (-1 != GNUNET_GNSRECORD_records_get_size (res_count, res));
 
 
@@ -1573,6 +1577,7 @@ store_record_set (struct NamestoreClient *nc,
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Name `%s' does not exist, no deletion required\n",
                   conv_name);
+      res = GNUNET_NO;
       ec = GNUNET_EC_NAMESTORE_RECORD_NOT_FOUND;
     }
     else
diff --git a/src/reclaim/plugin_rest_reclaim.c 
b/src/reclaim/plugin_rest_reclaim.c
index a2f8d96b2..9cc41bf1a 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/reclaim/plugin_rest_reclaim.c
@@ -317,7 +317,7 @@ do_error (void *cls)
     handle->response_code = MHD_HTTP_BAD_REQUEST;
   }
   resp = GNUNET_REST_create_response (json_error);
-  MHD_add_response_header (resp, "Content-Type", "application/json");
+  GNUNET_assert (MHD_NO != MHD_add_response_header (resp, "Content-Type", 
"application/json"));
   handle->proc (handle->proc_cls, resp, handle->response_code);
   cleanup_handle (handle);
   GNUNET_free (json_error);
@@ -1316,7 +1316,7 @@ options_cont (struct GNUNET_REST_RequestHandle 
*con_handle,
 
   // For now, independent of path return all options
   resp = GNUNET_REST_create_response (NULL);
-  MHD_add_response_header (resp, "Access-Control-Allow-Methods", 
allow_methods);
+  GNUNET_assert (MHD_NO != MHD_add_response_header (resp, 
"Access-Control-Allow-Methods", allow_methods));
   handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
   cleanup_handle (handle);
   return;
diff --git a/src/revocation/gnunet-revocation-tvg.c 
b/src/revocation/gnunet-revocation-tvg.c
index a34a6bc98..682f41530 100644
--- a/src/revocation/gnunet-revocation-tvg.c
+++ b/src/revocation/gnunet-revocation-tvg.c
@@ -107,6 +107,7 @@ run (void *cls,
   struct GNUNET_REVOCATION_PowCalculationHandle *ph;
   struct GNUNET_TIME_Relative exp;
   char ztld[128];
+  ssize_t key_len;
 
   id_priv.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA);
   GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key);
@@ -121,7 +122,9 @@ run (void *cls,
   print_bytes_ (&id_priv.ecdsa_key, sizeof(id_priv.ecdsa_key), 8, 1);
   fprintf (stdout, "\n");
   fprintf (stdout, "Zone identifier (ztype|zkey):\n");
-  print_bytes (&id_pub, GNUNET_IDENTITY_key_get_length (&id_pub), 8);
+  key_len = GNUNET_IDENTITY_key_get_length (&id_pub);
+  GNUNET_assert (0 < key_len);
+  print_bytes (&id_pub, key_len, 8);
   fprintf (stdout, "\n");
   fprintf (stdout, "Encoded zone identifier (zkl = zTLD):\n");
   fprintf (stdout, "%s\n", ztld);
diff --git a/src/util/client.c b/src/util/client.c
index f4e1b0f56..686e0562a 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -985,9 +985,9 @@ GNUNET_CLIENT_test (const struct 
GNUNET_CONFIGURATION_Handle *cfg,
 #if HAVE_SOCKADDR_IN_SUN_LEN
     v4.sin_len = (u_char) sizeof(struct sockaddr_in);
 #endif
-    inet_pton (AF_INET,
-               "127.0.0.1",
-               &v4.sin_addr);
+    GNUNET_assert (1 == inet_pton (AF_INET,
+                                   "127.0.0.1",
+                                   &v4.sin_addr));
     ret = GNUNET_NO;
     sock = socket (AF_INET,
                    SOCK_STREAM,
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c
index f516f5474..c910eb81c 100644
--- a/src/util/crypto_hash.c
+++ b/src/util/crypto_hash.c
@@ -316,7 +316,8 @@ GNUNET_CRYPTO_hmac_raw (const void *key, size_t key_len,
   {
     gcry_md_reset (md);
   }
-  gcry_md_setkey (md, key, key_len);
+  GNUNET_assert (GPG_ERR_NO_ERROR ==
+                 gcry_md_setkey (md, key, key_len));
   gcry_md_write (md, plaintext, plaintext_len);
   mc = gcry_md_read (md, GCRY_MD_SHA512);
   GNUNET_assert (NULL != mc);
diff --git a/src/util/gnunet-crypto-tvg.c b/src/util/gnunet-crypto-tvg.c
index 76c379784..6ec9229e3 100644
--- a/src/util/gnunet-crypto-tvg.c
+++ b/src/util/gnunet-crypto-tvg.c
@@ -640,6 +640,7 @@ checkvec (const char *operation,
       GNUNET_free (secret_enc_data);
       GNUNET_free (sig_enc_data);
       GNUNET_free (skey);
+      GNUNET_free (pkey);
       GNUNET_break (0);
       return GNUNET_NO;
     }
@@ -662,6 +663,8 @@ checkvec (const char *operation,
       GNUNET_free (secret_enc_data);
       GNUNET_free (sig_enc_data);
       GNUNET_free (skey);
+      GNUNET_free (sig);
+      GNUNET_free (pkey);
       GNUNET_break (0);
       return GNUNET_NO;
     }
@@ -670,6 +673,8 @@ checkvec (const char *operation,
     GNUNET_free (public_enc_data);
     GNUNET_free (secret_enc_data);
     GNUNET_free (sig_enc_data);
+    GNUNET_free (sig);
+    GNUNET_free (pkey);
     GNUNET_free (skey);
   }
   else if (0 == strcmp (operation, "cs_blind_signing"))
diff --git a/src/zonemaster/gnunet-service-zonemaster.c 
b/src/zonemaster/gnunet-service-zonemaster.c
index cbb448518..3d87e232b 100644
--- a/src/zonemaster/gnunet-service-zonemaster.c
+++ b/src/zonemaster/gnunet-service-zonemaster.c
@@ -412,7 +412,7 @@ shutdown_task (void *cls)
     GNUNET_CONTAINER_DLL_remove (cop_head, cop_tail, cop);
     GNUNET_free (cop);
   }
-
+  GNUNET_assert (0 == pthread_mutex_lock (&jobs_lock));
   while (NULL != (job = jobs_head))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -420,7 +420,8 @@ shutdown_task (void *cls)
     GNUNET_CONTAINER_DLL_remove (jobs_head, jobs_tail, job);
     free_job (job);
   }
-
+  GNUNET_assert (0 == pthread_mutex_unlock (&jobs_lock));
+  GNUNET_assert (0 == pthread_mutex_lock (&results_lock));
   while (NULL != (job = results_head))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -428,6 +429,7 @@ shutdown_task (void *cls)
     GNUNET_CONTAINER_DLL_remove (results_head, results_tail, job);
     free_job (job);
   }
+  GNUNET_assert (0 == pthread_mutex_unlock (&results_lock));
 
   while (NULL != (ma = it_head))
   {

-- 
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]