]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
confile: satisfy gcc-8 2313/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 10 May 2018 22:16:41 +0000 (00:16 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 10 May 2018 22:16:41 +0000 (00:16 +0200)
Apparently -Werror=stringop-overflow will trigger an error here even though
this is completely valid since we now that we're definitely copying a \0-byte.
Work around this gcc-8 quirk by using memcpy(). This shouldn't trigger the
warning.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/confile_utils.c

index 491b07034c587843945ff7e0460673fd56153dcc..fe5e078c45209e70d08e00df2c49704cf934af9e 100644 (file)
@@ -621,10 +621,14 @@ bool new_hwaddr(char *hwaddr)
 
 int lxc_get_conf_str(char *retv, int inlen, const char *value)
 {
+       size_t value_len;
+
        if (!value)
                return 0;
-       if (retv && inlen >= strlen(value) + 1)
-               strncpy(retv, value, strlen(value) + 1);
+
+       value_len = strlen(value);
+       if (retv && inlen >= value_len + 1)
+               memcpy(retv, value, value_len + 1);
 
        return strlen(value);
 }