From 3c513f3f62b1b4b425cdbabcbb8cc72c49478e6a Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 29 Apr 2019 18:18:51 +0300 Subject: [PATCH] Avoid compilation warnings in w32.c * 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/w32.c b/src/w32.c index 082a66b7384..677c37fcb5d 100644 --- 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; } -- 2.39.2