gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: -fix coverity


From: gnunet
Subject: [gnunet] branch master updated: -fix coverity
Date: Tue, 01 Nov 2022 03:32:46 +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 0f45038d2 -fix coverity
0f45038d2 is described below

commit 0f45038d25da3d3de3f83d04bcf30eca5da361d0
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Tue Nov 1 11:32:39 2022 +0900

    -fix coverity
---
 src/conversation/gnunet-service-conversation.c | 19 +++++++----
 src/gnsrecord/json_gnsrecord.c                 |  2 +-
 src/identity/identity_api.c                    |  5 ++-
 src/messenger/gnunet-service-messenger.c       | 10 ++++--
 src/namestore/gnunet-service-namestore.c       |  1 +
 src/reclaim/gnunet-service-reclaim.c           |  2 +-
 src/revocation/plugin_block_revocation.c       | 29 +++++++++++------
 src/testing/testing.c                          | 45 ++++++++++++--------------
 8 files changed, 67 insertions(+), 46 deletions(-)

diff --git a/src/conversation/gnunet-service-conversation.c 
b/src/conversation/gnunet-service-conversation.c
index a551bed1a..1fff8bd26 100644
--- a/src/conversation/gnunet-service-conversation.c
+++ b/src/conversation/gnunet-service-conversation.c
@@ -738,7 +738,7 @@ handle_client_audio_message (void *cls, const struct 
ClientAudioMessage *msg)
 static enum GNUNET_GenericReturnValue
 check_cadet_ring_message (void *cls, const struct CadetPhoneRingMessage *msg)
 {
-  //FIXME
+  // FIXME
   return GNUNET_OK;
 }
 
@@ -1181,6 +1181,18 @@ handle_client_call_message (void *cls, const struct 
ClientCallMessage *msg)
   rs.target_peer = msg->target;
   rs.expiration_time =
     GNUNET_TIME_absolute_hton (GNUNET_TIME_relative_to_absolute 
(RING_TIMEOUT));
+  key_len = ntohl (msg->key_len);
+  if (GNUNET_SYSERR ==
+      GNUNET_IDENTITY_read_private_key_from_buffer (&msg[1],
+                                                    key_len,
+                                                    &caller_id,
+                                                    &read))
+  {
+    GNUNET_break_op (0);
+    GNUNET_free (ch);
+    GNUNET_SERVICE_client_drop (line->client);
+    return;
+  }
   ch->line = line;
   GNUNET_CONTAINER_DLL_insert (line->channel_head, line->channel_tail, ch);
   ch->status = CS_CALLER_CALLING;
@@ -1192,11 +1204,6 @@ handle_client_call_message (void *cls, const struct 
ClientCallMessage *msg)
                                              &inbound_end,
                                              cadet_handlers);
   ch->mq = GNUNET_CADET_get_mq (ch->channel);
-  key_len = ntohl (msg->key_len);
-  GNUNET_IDENTITY_read_private_key_from_buffer (&msg[1],
-                                                key_len,
-                                                &caller_id,
-                                                &read);
   GNUNET_assert (read == key_len);
   GNUNET_IDENTITY_sign (&caller_id, &rs, &sig);
   sig_len = GNUNET_IDENTITY_signature_get_length (&sig);
diff --git a/src/gnsrecord/json_gnsrecord.c b/src/gnsrecord/json_gnsrecord.c
index 1c59d146e..2b840ab30 100644
--- a/src/gnsrecord/json_gnsrecord.c
+++ b/src/gnsrecord/json_gnsrecord.c
@@ -97,7 +97,7 @@ parse_record (json_t *data, struct GNUNET_GNSRECORD_Data *rd)
   unpack_state = json_unpack_ex (data,
                                  &err,
                                  0,
-                                 "{s:s, s:s, s:i, s:b, s:b, s:b, s:b}",
+                                 "{s:s, s:s, s:I, s:b, s:b, s:b, s:b}",
                                  GNUNET_JSON_GNSRECORD_VALUE,
                                  &value,
                                  GNUNET_JSON_GNSRECORD_TYPE,
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c
index 4abd62434..3fd052277 100644
--- a/src/identity/identity_api.c
+++ b/src/identity/identity_api.c
@@ -157,14 +157,17 @@ GNUNET_IDENTITY_ego_get_anonymous ()
 {
   static struct GNUNET_IDENTITY_Ego anon;
   static int setup;
+  ssize_t key_len;
 
   if (setup)
     return &anon;
   anon.pk.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA);
   anon.pub.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA);
   anon.pk.ecdsa_key = *GNUNET_CRYPTO_ecdsa_key_get_anonymous ();
+  key_len = GNUNET_IDENTITY_private_key_get_length (&anon.pk);
+  GNUNET_assert (0 < key_len);
   GNUNET_CRYPTO_hash (&anon.pk,
-                      GNUNET_IDENTITY_private_key_get_length (&anon.pk),
+                      key_len,
                       &anon.id);
   setup = 1;
   return &anon;
diff --git a/src/messenger/gnunet-service-messenger.c 
b/src/messenger/gnunet-service-messenger.c
index a2b6ad81e..a4b46773d 100644
--- a/src/messenger/gnunet-service-messenger.c
+++ b/src/messenger/gnunet-service-messenger.c
@@ -261,9 +261,13 @@ handle_send_message (void *cls,
   struct GNUNET_IDENTITY_PublicKey public_key;
 
   if (flags & GNUNET_MESSENGER_FLAG_PRIVATE)
-    GNUNET_IDENTITY_read_public_key_from_buffer (
-      buffer, length, &public_key, &key_length);
-
+  {
+    GNUNET_assert (GNUNET_SYSERR !=
+                   GNUNET_IDENTITY_read_public_key_from_buffer (buffer,
+                                                                length,
+                                                                &public_key,
+                                                                &key_length));
+  }
   const uint16_t msg_length = length - key_length;
   const char*msg_buffer = buffer + key_length;
 
diff --git a/src/namestore/gnunet-service-namestore.c 
b/src/namestore/gnunet-service-namestore.c
index f0739cbeb..9173d2e4d 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -2525,6 +2525,7 @@ handle_monitor_start (void *cls, const struct
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                   "Error reading private key\n");
       GNUNET_SERVICE_client_drop (nc->client);
+      GNUNET_free (zm);
       return;
     }
     zm->zone = zone;
diff --git a/src/reclaim/gnunet-service-reclaim.c 
b/src/reclaim/gnunet-service-reclaim.c
index ea97f8749..4c80d6d24 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -913,7 +913,7 @@ handle_revoke_ticket_message (void *cls, const struct 
RevokeTicketMessage *rm)
   buf += read;
   tkt_len = ntohl (rm->tkt_len);
   if ((GNUNET_SYSERR ==
-       GNUNET_RECLAIM_read_ticket_from_buffer (buf, key_len,
+       GNUNET_RECLAIM_read_ticket_from_buffer (buf, tkt_len,
                                                &ticket, &read)) ||
       (read != tkt_len))
   {
diff --git a/src/revocation/plugin_block_revocation.c 
b/src/revocation/plugin_block_revocation.c
index 0c81440eb..7de4fafe9 100644
--- a/src/revocation/plugin_block_revocation.c
+++ b/src/revocation/plugin_block_revocation.c
@@ -114,11 +114,16 @@ block_plugin_revocation_check_block (void *cls,
     return GNUNET_NO;
   }
   left = block_size - sizeof (*rm) - sizeof (*pow);
-  GNUNET_IDENTITY_read_public_key_from_buffer (&pow[1],
-                                               left,
-                                               &pk,
-                                               &pklen);
-  if (0 > pklen)
+  if (GNUNET_SYSERR ==
+      GNUNET_IDENTITY_read_public_key_from_buffer (&pow[1],
+                                                   left,
+                                                   &pk,
+                                                   &pklen))
+  {
+    GNUNET_break_op (0);
+    return GNUNET_NO;
+  }
+  if (0 == pklen)
   {
     GNUNET_break_op (0);
     return GNUNET_NO;
@@ -219,11 +224,15 @@ block_plugin_revocation_get_key (void *cls,
     return GNUNET_NO;
   }
   left = block_size - sizeof (*rm) - sizeof (*pow);
-  GNUNET_IDENTITY_read_public_key_from_buffer (&pow[1],
-                                               left,
-                                               &pk,
-                                               &pklen);
-  if (0 > pklen)
+  if (GNUNET_SYSERR == GNUNET_IDENTITY_read_public_key_from_buffer (&pow[1],
+                                                                    left,
+                                                                    &pk,
+                                                                    &pklen))
+  {
+    GNUNET_break_op (0);
+    return GNUNET_NO;
+  }
+  if (0 == pklen)
   {
     GNUNET_break_op (0);
     return GNUNET_NO;
diff --git a/src/testing/testing.c b/src/testing/testing.c
index e6f073f63..d18197860 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -2499,8 +2499,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
     }
     else if (0 == strcmp (key, "K"))
     {
-      struct GNUNET_ShortHashCode *hkey_k = GNUNET_new (struct
-                                                        GNUNET_ShortHashCode);
+      struct GNUNET_ShortHashCode hkey_k;
       struct GNUNET_TESTING_NetjailNode *k_node = GNUNET_new (struct
                                                               
GNUNET_TESTING_NetjailNode);
 
@@ -2512,18 +2511,18 @@ GNUNET_TESTING_get_topo_from_string (char *data)
            out);
       k_node->node_n = out;
       GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
-      memcpy (hkey_k,
+      memcpy (&hkey_k,
               &hc,
-              sizeof (*hkey_k));
+              sizeof (hkey_k));
       k_node->is_global = GNUNET_YES;
 
       if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains (
             topo->map_globals,
-            hkey_k))
+            &hkey_k))
         GNUNET_break (0);
       else
         GNUNET_CONTAINER_multishortmap_put (topo->map_globals,
-                                            hkey_k,
+                                            &hkey_k,
                                             k_node,
                                             
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
       LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2539,8 +2538,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
     }
     else if (0 == strcmp (key, "R"))
     {
-      struct GNUNET_ShortHashCode *hkey_r = GNUNET_new (struct
-                                                        GNUNET_ShortHashCode);
+      struct GNUNET_ShortHashCode hkey_r;
       router = GNUNET_new (struct GNUNET_TESTING_NetjailRouter);
 
       LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2550,9 +2548,9 @@ GNUNET_TESTING_get_topo_from_string (char *data)
            "R: %u\n",
            out);
       GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
-      memcpy (hkey_r,
+      memcpy (&hkey_r,
               &hc,
-              sizeof (*hkey_r));
+              sizeof (hkey_r));
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Get value for key tcp_port on R.\n");
       value = get_value ("tcp_port", token);
@@ -2575,10 +2573,10 @@ GNUNET_TESTING_get_topo_from_string (char *data)
       GNUNET_free (value2);
       if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains (
             topo->map_namespaces,
-            hkey_r))
+            &hkey_r))
       {
         namespace = GNUNET_CONTAINER_multishortmap_get (topo->map_namespaces,
-                                                        hkey_r);
+                                                        &hkey_r);
       }
       else
       {
@@ -2586,7 +2584,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
         namespace->namespace_n = out;
         namespace->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
         GNUNET_CONTAINER_multishortmap_put (topo->map_namespaces,
-                                            hkey_r,
+                                            &hkey_r,
                                             namespace,
                                             
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
       }
@@ -2597,8 +2595,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
     {
       struct GNUNET_TESTING_NetjailNode *p_node = GNUNET_new (struct
                                                               
GNUNET_TESTING_NetjailNode);
-      struct GNUNET_ShortHashCode *hkey_p = GNUNET_new (struct
-                                                        GNUNET_ShortHashCode);
+      struct GNUNET_ShortHashCode hkey_p;
 
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Get first Value for P.\n");
@@ -2607,16 +2604,16 @@ GNUNET_TESTING_get_topo_from_string (char *data)
            "P: %u\n",
            out);
       GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
-      memcpy (hkey_p,
+      memcpy (&hkey_p,
               &hc,
-              sizeof (*hkey_p));
+              sizeof (hkey_p));
 
       if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains (
             topo->map_namespaces,
-            hkey_p))
+            &hkey_p))
       {
         namespace = GNUNET_CONTAINER_multishortmap_get (topo->map_namespaces,
-                                                        hkey_p);
+                                                        &hkey_p);
       }
       else
       {
@@ -2624,7 +2621,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
         namespace->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
         namespace->namespace_n = out;
         GNUNET_CONTAINER_multishortmap_put (topo->map_namespaces,
-                                            hkey_p,
+                                            &hkey_p,
                                             namespace,
                                             
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
       }
@@ -2635,12 +2632,12 @@ GNUNET_TESTING_get_topo_from_string (char *data)
            "P: %u\n",
            out);
       GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
-      memcpy (hkey_p,
+      memcpy (&hkey_p,
               &hc,
-              sizeof (*hkey_p));
+              sizeof (hkey_p));
       if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains (
             namespace->nodes,
-            hkey_p))
+            &hkey_p))
       {
         GNUNET_break (0);
       }
@@ -2648,7 +2645,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
       {
 
         GNUNET_CONTAINER_multishortmap_put (namespace->nodes,
-                                            hkey_p,
+                                            &hkey_p,
                                             p_node,
                                             
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
         LOG (GNUNET_ERROR_TYPE_DEBUG,

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