gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated (4c2a06deb -> 3ea320df4)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (4c2a06deb -> 3ea320df4)
Date: Thu, 27 Jun 2019 13:00:30 +0200

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

lurchi pushed a change to branch master
in repository gnunet.

    from 4c2a06deb memcpy fits better
     new 40a111b93 return value of GNUNET_strlcpy can be used
     new 3ea320df4 new GNUNET_strlcpy allows using it more

The 2 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/exit/gnunet-helper-exit-windows.c |  3 ---
 src/testbed/gnunet-helper-testbed.c   |  7 +++----
 src/testbed/gnunet-service-testbed.c  |  8 ++------
 src/testbed/testbed_api_hosts.c       | 16 ++++++----------
 src/util/gnunet-ecc.c                 |  3 +--
 src/vpn/gnunet-helper-vpn-windows.c   |  3 ---
 6 files changed, 12 insertions(+), 28 deletions(-)

diff --git a/src/exit/gnunet-helper-exit-windows.c 
b/src/exit/gnunet-helper-exit-windows.c
index 2e4b5f4a2..8bae7ca86 100644
--- a/src/exit/gnunet-helper-exit-windows.c
+++ b/src/exit/gnunet-helper-exit-windows.c
@@ -749,9 +749,6 @@ resolve_interface_name ()
           /*
            * we have successfully found OUR instance,
            * save the device GUID before exiting
-           *
-           * We can use GNUNET_strlcpy here because instance key is null-
-           * terminated by RegEnumKeyExA.
            */
           GNUNET_strlcpy (device_guid, instance_key, sizeof (device_guid));
           retval = TRUE;
diff --git a/src/testbed/gnunet-helper-testbed.c 
b/src/testbed/gnunet-helper-testbed.c
index c56a795a6..687a54bcd 100644
--- a/src/testbed/gnunet-helper-testbed.c
+++ b/src/testbed/gnunet-helper-testbed.c
@@ -374,10 +374,9 @@ tokenizer_cb (void *cls,
   if (0 != hostname_size)
   {
     hostname = GNUNET_malloc (hostname_size + 1);
-    /* intentionally use strncpy (hostname not null terminated) */
-    (void) strncpy (hostname, ((char *) &msg[1]) + trusted_ip_size + 1,
-                    hostname_size);
-    hostname[hostname_size] = '\0';
+    GNUNET_strlcpy (hostname,
+                    ((char *) &msg[1]) + trusted_ip_size + 1,
+                    hostname_size + 1);
   }
   /* unset GNUNET_TESTING_PREFIX if present as it is more relevant for testbed 
*/
   evstr = getenv (GNUNET_TESTING_PREFIX);
diff --git a/src/testbed/gnunet-service-testbed.c 
b/src/testbed/gnunet-service-testbed.c
index d740d31bc..289e17349 100644
--- a/src/testbed/gnunet-service-testbed.c
+++ b/src/testbed/gnunet-service-testbed.c
@@ -541,15 +541,11 @@ handle_add_host (void *cls,
   if (0 != username_length)
   {
     username = GNUNET_malloc (username_length + 1);
-    /* intentionally use strncpy (message payload is not null terminated) */
-    strncpy (username, ptr, username_length);
+    GNUNET_strlcpy (username, ptr, username_length + 1);
     ptr += username_length;
   }
   hostname = GNUNET_malloc (hostname_length + 1);
-  /* intentionally use strncpy (message payload is not null terminated) */
-  strncpy (hostname,
-           ptr,
-           hostname_length);
+  GNUNET_strlcpy (hostname, ptr, hostname_length + 1);
   if (NULL == (host_cfg = GNUNET_TESTBED_extract_config_ (&msg->header)))
   {
     GNUNET_free_non_null (username);
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c
index d6521f766..6dbd99bc9 100644
--- a/src/testbed/testbed_api_hosts.c
+++ b/src/testbed/testbed_api_hosts.c
@@ -462,11 +462,9 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
       {
         size = pmatch[2].rm_eo - pmatch[2].rm_so;
         username = GNUNET_malloc (size + 1);
-        /*
-         * Intentionally use strncpy (buf is not necessarily null-terminated)
-         */
-        username[size] = '\0';
-        GNUNET_assert (NULL != strncpy (username, buf + pmatch[2].rm_so, 
size));
+        GNUNET_assert(0 != GNUNET_strlcpy (username,
+                                           buf + pmatch[2].rm_so,
+                                           size + 1));
       }
       if (-1 != pmatch[5].rm_so)
       {
@@ -474,11 +472,9 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename,
       }
       size = pmatch[3].rm_eo - pmatch[3].rm_so;
       hostname = GNUNET_malloc (size + 1);
-      /*
-       * Intentionally use strncpy (buf is not necessarily null-terminated)
-       */
-      hostname[size] = '\0';
-      GNUNET_assert (NULL != strncpy (hostname, buf + pmatch[3].rm_so, size));
+      GNUNET_assert(0 != GNUNET_strlcpy (hostname,
+                                         buf + pmatch[3].rm_so,
+                                         size + 1));
       LOG (GNUNET_ERROR_TYPE_DEBUG,
            "Successfully read host %s, port %d and user %s from file\n",
            (NULL == hostname) ? "NULL" : hostname,
diff --git a/src/util/gnunet-ecc.c b/src/util/gnunet-ecc.c
index 94ffb4308..d2253337c 100644
--- a/src/util/gnunet-ecc.c
+++ b/src/util/gnunet-ecc.c
@@ -96,8 +96,7 @@ create_keys (const char *fn, const char *prefix)
   }
   if (NULL != prefix)
   {
-    GNUNET_strlcpy (vanity, prefix, sizeof (vanity));
-    len = GNUNET_MIN (strlen (prefix), KEY_STR_LEN);
+    len = GNUNET_strlcpy (vanity, prefix, sizeof (vanity));
     n = len * 5 / 8;
     rest = len * 5 % 8;
 
diff --git a/src/vpn/gnunet-helper-vpn-windows.c 
b/src/vpn/gnunet-helper-vpn-windows.c
index ab72d71aa..17f32c5a8 100644
--- a/src/vpn/gnunet-helper-vpn-windows.c
+++ b/src/vpn/gnunet-helper-vpn-windows.c
@@ -751,9 +751,6 @@ resolve_interface_name ()
           /*
            * we have successfully found OUR instance,
            * save the device GUID before exiting
-           *
-           * We can use GNUNET_strlcpy here because instance key is null-
-           * terminated by RegEnumKeyExA.
            */
           GNUNET_strlcpy (device_guid, instance_key, sizeof (device_guid));
           retval = TRUE;

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

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