gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated (fa48dbb24 -> 1567c9472)


From: gnunet
Subject: [gnunet] branch master updated (fa48dbb24 -> 1567c9472)
Date: Tue, 25 Oct 2022 10:44:30 +0200

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

t3sserakt pushed a change to branch master
in repository gnunet.

    from fa48dbb24 Merge branch 'master' of git+ssh://git.gnunet.org/gnunet
     new 9a5252497 - fixing coverity findings
     new c5f3eb40c Merge branch 'master' of ssh://git.gnunet.org/gnunet
     new b3a761005 Merge branch 'master' of ssh://git.gnunet.org/gnunet
     new 1567c9472 - fixed coverity findings

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/testing/gnunet-cmds-helper.c                   |  2 +-
 src/testing/testing.c                              | 62 +++++++++++++---------
 src/transport/gnunet-communicator-tcp.c            |  2 +
 src/transport/gnunet-communicator-udp.c            |  1 +
 .../test_transport_plugin_cmd_simple_send.c        |  4 +-
 ...st_transport_plugin_cmd_simple_send_broadcast.c | 31 +++++++++--
 .../test_transport_plugin_cmd_simple_send_dv.c     | 30 +++++++++--
 .../test_transport_plugin_cmd_udp_backchannel.c    | 38 +++++++++++--
 .../transport_api_cmd_backchannel_check.c          | 11 ++--
 9 files changed, 135 insertions(+), 46 deletions(-)

diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c
index be58f6f6a..8114d156d 100644
--- a/src/testing/gnunet-cmds-helper.c
+++ b/src/testing/gnunet-cmds-helper.c
@@ -606,7 +606,7 @@ main (int argc, char **argv)
   int i;
   size_t topology_data_length = 0;
   unsigned int read_file;
-  char cr[1] = "\n";
+  char cr[2] = "\n\0";
 
   GNUNET_log_setup ("gnunet-cmds-helper",
                     "DEBUG",
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 22375bc98..e6f073f63 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -2065,6 +2065,7 @@ get_node_info (unsigned int num,
                struct GNUNET_TESTING_NodeConnection **node_connections_ex)
 {
   struct GNUNET_ShortHashCode *hkey;
+  struct GNUNET_ShortHashCode *hkey_node;
   struct GNUNET_HashCode hc;
   unsigned int namespace_n;
   unsigned int node_m;
@@ -2102,7 +2103,6 @@ get_node_info (unsigned int num,
          topology->nodes_x,
          topology->nodes_m,
          namespace_n);
-    hkey = GNUNET_new (struct GNUNET_ShortHashCode);
     GNUNET_CRYPTO_hash (&namespace_n, sizeof(namespace_n), &hc);
     memcpy (hkey,
             &hc,
@@ -2112,7 +2112,7 @@ get_node_info (unsigned int num,
     if (NULL != namespace)
     {
       node_m = num - topology->nodes_x - topology->nodes_m * (namespace_n - 1);
-      hkey = GNUNET_new (struct GNUNET_ShortHashCode);
+      hkey_node = GNUNET_new (struct GNUNET_ShortHashCode);
       GNUNET_CRYPTO_hash (&node_m, sizeof(node_m), &hc);
       memcpy (hkey,
               &hc,
@@ -2130,9 +2130,10 @@ get_node_info (unsigned int num,
       *node_ex = node;
       *namespace_ex = namespace;
       *node_connections_ex = node_connections;
+      GNUNET_free (hkey_node);
     }
-    GNUNET_free (hkey);
   }
+  GNUNET_free (hkey);
 }
 
 
@@ -2382,6 +2383,7 @@ static void
 parse_ac (struct GNUNET_TESTING_NetjailNode *p_node, char *token)
 {
   char *ac_value;
+  int ret;
 
   ac_value = get_value ("AC", token);
   if (NULL != ac_value)
@@ -2389,7 +2391,13 @@ parse_ac (struct GNUNET_TESTING_NetjailNode *p_node, 
char *token)
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "ac value: %s\n",
          ac_value);
-    sscanf (ac_value, "%u", &p_node->additional_connects);
+    errno = 0;
+    ret = sscanf (ac_value, "%u", &p_node->additional_connects);
+    if (errno != 0)
+    {
+      GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf");
+    }
+    GNUNET_assert (0 < ret);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
          "AC %u\n",
          p_node->additional_connects);
@@ -2421,7 +2429,6 @@ GNUNET_TESTING_get_topo_from_string (char *data)
   struct GNUNET_TESTING_NetjailTopology *topo;
   struct GNUNET_TESTING_NetjailRouter *router;
   struct GNUNET_TESTING_NetjailNamespace *namespace;
-  struct GNUNET_ShortHashCode *hkey;
   struct GNUNET_HashCode hc;
 
   token = strtok_r (data, "\n", &rest);
@@ -2492,7 +2499,8 @@ GNUNET_TESTING_get_topo_from_string (char *data)
     }
     else if (0 == strcmp (key, "K"))
     {
-      hkey = GNUNET_new (struct GNUNET_ShortHashCode);
+      struct GNUNET_ShortHashCode *hkey_k = GNUNET_new (struct
+                                                        GNUNET_ShortHashCode);
       struct GNUNET_TESTING_NetjailNode *k_node = GNUNET_new (struct
                                                               
GNUNET_TESTING_NetjailNode);
 
@@ -2504,18 +2512,18 @@ GNUNET_TESTING_get_topo_from_string (char *data)
            out);
       k_node->node_n = out;
       GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
-      memcpy (hkey,
+      memcpy (hkey_k,
               &hc,
-              sizeof (*hkey));
+              sizeof (*hkey_k));
       k_node->is_global = GNUNET_YES;
 
       if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains (
             topo->map_globals,
-            hkey))
+            hkey_k))
         GNUNET_break (0);
       else
         GNUNET_CONTAINER_multishortmap_put (topo->map_globals,
-                                            hkey,
+                                            hkey_k,
                                             k_node,
                                             
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
       LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2531,7 +2539,8 @@ GNUNET_TESTING_get_topo_from_string (char *data)
     }
     else if (0 == strcmp (key, "R"))
     {
-      hkey = GNUNET_new (struct GNUNET_ShortHashCode);
+      struct GNUNET_ShortHashCode *hkey_r = GNUNET_new (struct
+                                                        GNUNET_ShortHashCode);
       router = GNUNET_new (struct GNUNET_TESTING_NetjailRouter);
 
       LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2541,9 +2550,9 @@ GNUNET_TESTING_get_topo_from_string (char *data)
            "R: %u\n",
            out);
       GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
-      memcpy (hkey,
+      memcpy (hkey_r,
               &hc,
-              sizeof (*hkey));
+              sizeof (*hkey_r));
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Get value for key tcp_port on R.\n");
       value = get_value ("tcp_port", token);
@@ -2566,10 +2575,10 @@ GNUNET_TESTING_get_topo_from_string (char *data)
       GNUNET_free (value2);
       if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains (
             topo->map_namespaces,
-            hkey))
+            hkey_r))
       {
         namespace = GNUNET_CONTAINER_multishortmap_get (topo->map_namespaces,
-                                                        hkey);
+                                                        hkey_r);
       }
       else
       {
@@ -2577,7 +2586,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,
+                                            hkey_r,
                                             namespace,
                                             
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
       }
@@ -2588,7 +2597,8 @@ GNUNET_TESTING_get_topo_from_string (char *data)
     {
       struct GNUNET_TESTING_NetjailNode *p_node = GNUNET_new (struct
                                                               
GNUNET_TESTING_NetjailNode);
-      hkey = GNUNET_new (struct GNUNET_ShortHashCode);
+      struct GNUNET_ShortHashCode *hkey_p = GNUNET_new (struct
+                                                        GNUNET_ShortHashCode);
 
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Get first Value for P.\n");
@@ -2597,16 +2607,16 @@ GNUNET_TESTING_get_topo_from_string (char *data)
            "P: %u\n",
            out);
       GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
-      memcpy (hkey,
+      memcpy (hkey_p,
               &hc,
-              sizeof (*hkey));
+              sizeof (*hkey_p));
 
       if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains (
             topo->map_namespaces,
-            hkey))
+            hkey_p))
       {
         namespace = GNUNET_CONTAINER_multishortmap_get (topo->map_namespaces,
-                                                        hkey);
+                                                        hkey_p);
       }
       else
       {
@@ -2614,7 +2624,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,
+                                            hkey_p,
                                             namespace,
                                             
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
       }
@@ -2625,12 +2635,12 @@ GNUNET_TESTING_get_topo_from_string (char *data)
            "P: %u\n",
            out);
       GNUNET_CRYPTO_hash (&out, sizeof(out), &hc);
-      memcpy (hkey,
+      memcpy (hkey_p,
               &hc,
-              sizeof (*hkey));
+              sizeof (*hkey_p));
       if (GNUNET_YES == GNUNET_CONTAINER_multishortmap_contains (
             namespace->nodes,
-            hkey))
+            hkey_p))
       {
         GNUNET_break (0);
       }
@@ -2638,7 +2648,7 @@ GNUNET_TESTING_get_topo_from_string (char *data)
       {
 
         GNUNET_CONTAINER_multishortmap_put (namespace->nodes,
-                                            hkey,
+                                            hkey_p,
                                             p_node,
                                             
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
         LOG (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/transport/gnunet-communicator-tcp.c 
b/src/transport/gnunet-communicator-tcp.c
index 4820caf70..a8dbed604 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -3554,6 +3554,8 @@ run (void *cls,
   socklen_t addr_len_ipv6;
 
   (void) cls;
+  memset (&v4,0,sizeof(struct sockaddr_in));
+  memset (&v6,0,sizeof(struct sockaddr_in6));
   cfg = c;
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_string (cfg,
diff --git a/src/transport/gnunet-communicator-udp.c 
b/src/transport/gnunet-communicator-udp.c
index 2748a6594..282902f1c 100644
--- a/src/transport/gnunet-communicator-udp.c
+++ b/src/transport/gnunet-communicator-udp.c
@@ -2367,6 +2367,7 @@ sock_read (void *cls)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Received our own broadcast\n");
+      GNUNET_free (addr_verify);
       return;
     }
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c 
b/src/transport/test_transport_plugin_cmd_simple_send.c
index ee6b9669b..5941a991b 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send.c
@@ -113,14 +113,11 @@ handle_result (void *cls,
                enum GNUNET_GenericReturnValue rv)
 {
   struct TestState *ts = cls;
-  struct GNUNET_MessageHeader *reply;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Local test exits with status %d\n",
               rv);
 
-  reply = GNUNET_TESTING_send_local_test_finished_msg ();
-
   ts->finished_cb ();
   GNUNET_free (ts->testdir);
   GNUNET_free (ts->cfgname);
@@ -238,6 +235,7 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, 
char *router_ip,
     GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf");
   }
   GNUNET_assert (0 < sscanf_ret);
+
   if (0 == n_int)
     num = m_int;
   else
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c 
b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
index 6254dba36..3a282bb11 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send_broadcast.c
@@ -226,9 +226,14 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, 
char *router_ip,
   unsigned int num;
   struct TestState *ts = GNUNET_new (struct TestState);
   struct GNUNET_TESTING_NetjailTopology *topology;
-
+  unsigned int sscanf_ret = 0;
 
   ts->finished_cb = finished_cb;
+  LOG (GNUNET_ERROR_TYPE_ERROR,
+       "n %s m %s\n",
+       n,
+       m);
+
   if (GNUNET_YES == *read_file)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -240,9 +245,27 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, 
char *router_ip,
 
   ts->topology = topology;
 
-  sscanf (m, "%u", &m_int);
-  sscanf (n, "%u", &n_int);
-  sscanf (local_m, "%u", &local_m_int);
+  errno = 0;
+  sscanf_ret = sscanf (m, "%u", &m_int);
+  if (errno != 0)
+  {
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf");
+  }
+  GNUNET_assert (0 < sscanf_ret);
+  errno = 0;
+  sscanf_ret = sscanf (n, "%u", &n_int);
+  if (errno != 0)
+  {
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf");
+  }
+  GNUNET_assert (0 < sscanf_ret);
+  errno = 0;
+  sscanf_ret = sscanf (local_m, "%u", &local_m_int);
+  if (errno != 0)
+  {
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf");
+  }
+  GNUNET_assert (0 < sscanf_ret);
 
   if (0 == n_int)
     num = m_int;
diff --git a/src/transport/test_transport_plugin_cmd_simple_send_dv.c 
b/src/transport/test_transport_plugin_cmd_simple_send_dv.c
index ea0c9aea8..8bfa1fd0a 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send_dv.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send_dv.c
@@ -256,8 +256,14 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, 
char *router_ip,
                            ts),
     GNUNET_MQ_handler_end ()
   };
+  unsigned int sscanf_ret = 0;
 
   ts->finished_cb = finished_cb;
+  LOG (GNUNET_ERROR_TYPE_ERROR,
+       "n %s m %s\n",
+       n,
+       m);
+
   if (GNUNET_YES == *read_file)
   {
     LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -269,9 +275,27 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, 
char *router_ip,
 
   ts->topology = topology;
 
-  sscanf (m, "%u", &m_int);
-  sscanf (n, "%u", &n_int);
-  sscanf (local_m, "%u", &local_m_int);
+  errno = 0;
+  sscanf_ret = sscanf (m, "%u", &m_int);
+  if (errno != 0)
+  {
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf");
+  }
+  GNUNET_assert (0 < sscanf_ret);
+  errno = 0;
+  sscanf_ret = sscanf (n, "%u", &n_int);
+  if (errno != 0)
+  {
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf");
+  }
+  GNUNET_assert (0 < sscanf_ret);
+  errno = 0;
+  sscanf_ret = sscanf (local_m, "%u", &local_m_int);
+  if (errno != 0)
+  {
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf");
+  }
+  GNUNET_assert (0 < sscanf_ret);
 
   if (0 == n_int)
     num = m_int;
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c 
b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
index 87065e340..5a0dac32b 100644
--- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c
+++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
@@ -34,7 +34,7 @@
 /**
  * Generic logging shortcut
  */
-#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "udp-backchannel", __VA_ARGS__)
 
 #define BASE_DIR "testdir"
 
@@ -187,18 +187,46 @@ start_testcase (TESTING_CMD_HELPER_write_cb 
write_message, char *router_ip,
   unsigned int num;
   struct TestState *ts = GNUNET_new (struct TestState);
   struct GNUNET_TESTING_NetjailTopology *topology;
+  unsigned int sscanf_ret = 0;
 
   ts->finished_cb = finished_cb;
+  LOG (GNUNET_ERROR_TYPE_ERROR,
+       "n %s m %s\n",
+       n,
+       m);
+
   if (GNUNET_YES == *read_file)
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "read from file\n");
     topology = GNUNET_TESTING_get_topo_from_file (topology_data);
+  }
   else
     topology = GNUNET_TESTING_get_topo_from_string (topology_data);
 
   ts->topology = topology;
 
-  sscanf (m, "%u", &m_int);
-  sscanf (n, "%u", &n_int);
-  sscanf (local_m, "%u", &local_m_int);
+  errno = 0;
+  sscanf_ret = sscanf (m, "%u", &m_int);
+  if (errno != 0)
+  {
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf");
+  }
+  GNUNET_assert (0 < sscanf_ret);
+  errno = 0;
+  sscanf_ret = sscanf (n, "%u", &n_int);
+  if (errno != 0)
+  {
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf");
+  }
+  GNUNET_assert (0 < sscanf_ret);
+  errno = 0;
+  sscanf_ret = sscanf (local_m, "%u", &local_m_int);
+  if (errno != 0)
+  {
+    GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sscanf");
+  }
+  GNUNET_assert (0 < sscanf_ret);
 
 
   if (0 == n_int)
@@ -296,7 +324,7 @@ libgnunet_test_transport_plugin_cmd_udp_backchannel_init 
(void *cls)
 
   GNUNET_log_setup ("udp-backchannel",
                     "DEBUG",
-                    NULL);
+                    "plugin.out");
 
   api = GNUNET_new (struct GNUNET_TESTING_PluginFunctions);
   api->start_testcase = &start_testcase;
diff --git a/src/transport/transport_api_cmd_backchannel_check.c 
b/src/transport/transport_api_cmd_backchannel_check.c
index 1edd6cb7e..0376275a3 100644
--- a/src/transport/transport_api_cmd_backchannel_check.c
+++ b/src/transport/transport_api_cmd_backchannel_check.c
@@ -36,7 +36,7 @@
 /**
  * Generic logging shortcut
  */
-#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "udp-backchannel",__VA_ARGS__)
 
 #define UDP "udp"
 
@@ -413,6 +413,9 @@ backchannel_check_run (void *cls,
   const struct GNUNET_TESTING_NetjailNode *node;
   const struct GNUNET_TESTING_NetjailNamespace *namespace;
 
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "check run 1\n");
+
   peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
                                                          cs->start_peer_label);
   GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd,
@@ -429,7 +432,7 @@ backchannel_check_run (void *cls,
                                                               cs->topology);
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "check run\n");
+       "check run 2\n");
 
 
   node_it = GNUNET_CONTAINER_multishortmap_iterator_create (
@@ -450,6 +453,7 @@ backchannel_check_run (void *cls,
       add_search_string (cs, node);
     }
   }
+  GNUNET_free (node_it);
   namespace_it = GNUNET_CONTAINER_multishortmap_iterator_create (
     cs->topology->map_namespaces);
   while (GNUNET_YES == GNUNET_CONTAINER_multishortmap_iterator_next (
@@ -478,6 +482,7 @@ backchannel_check_run (void *cls,
         add_search_string (cs, node);
       }
     }
+    GNUNET_free (node_it);
   }
 
   if (0 != cs->con_num)
@@ -490,8 +495,6 @@ backchannel_check_run (void *cls,
     GNUNET_TESTING_async_finish (&cs->ac);
 
   GNUNET_free (namespace_it);
-  GNUNET_free (node_it);
-
 }
 
 

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