From: Christian Brauner Date: Thu, 10 May 2018 22:16:41 +0000 (+0200) Subject: confile: satisfy gcc-8 X-Git-Tag: lxc-3.1.0~312^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2313%2Fhead;p=thirdparty%2Flxc.git confile: satisfy gcc-8 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 --- diff --git a/src/lxc/confile_utils.c b/src/lxc/confile_utils.c index 491b07034..fe5e078c4 100644 --- a/src/lxc/confile_utils.c +++ b/src/lxc/confile_utils.c @@ -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); }