]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid compilation warnings in w32.c
authorEli Zaretskii <eliz@gnu.org>
Mon, 29 Apr 2019 15:18:51 +0000 (18:18 +0300)
committerEli Zaretskii <eliz@gnu.org>
Mon, 29 Apr 2019 15:18:51 +0000 (18:18 +0300)
* src/w32.c (unsetenv, readlink): Use memcpy instead of
strncpy, to avoid a compiler warning about calculating the
bound of the copy.

src/w32.c

index 082a66b738428da5bdfbb9022a494de0906e18d6..677c37fcb5d1ecb03cc1aab16f62047d4c080fdd 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -2644,7 +2644,7 @@ unsetenv (const char *name)
   /* It is safe to use 'alloca' with 32K size, since the stack is at
      least 2MB, and we set it to 8MB in the link command line.  */
   var = alloca (name_len + 2);
-  strncpy (var, name, name_len);
+  memcpy (var, name, name_len);
   var[name_len++] = '=';
   var[name_len] = '\0';
   return _putenv (var);
@@ -6054,7 +6054,7 @@ readlink (const char *name, char *buf, size_t buf_size)
          lname_size = strlen (resolved) + 1;
          if (lname_size <= buf_size)
            size_to_copy = lname_size;
-         strncpy (buf, resolved, size_to_copy);
+         memcpy (buf, resolved, size_to_copy);
          /* Success!  */
          retval = size_to_copy;
        }