From: Jérémie Galarneau Date: Fri, 1 Jun 2018 16:50:40 +0000 (-0400) Subject: Silence strncpy warning emitted by GCC 8 in ini parser X-Git-Tag: v2.11.0-rc1~196 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9ff0b09b3a6d4469ff42e489abc78352f42ebae8;p=lttng-tools.git Silence strncpy warning emitted by GCC 8 in ini parser While copying 'dst len' bytes in strncpy is normally risky as the dst may not be NULL-terminated, this function ensures that the last byte of 'dst' is NULL. Therefore, this change is mostly made to silence GCC. Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/config/ini.c b/src/common/config/ini.c index 34e3abf8a..41d299a19 100644 --- a/src/common/config/ini.c +++ b/src/common/config/ini.c @@ -82,7 +82,7 @@ static char* find_char_or_comment(const char* s, char c) /* Version of strncpy that ensures dest (size bytes) is null-terminated. */ static char* strncpy0(char* dest, const char* src, size_t size) { - strncpy(dest, src, size); + strncpy(dest, src, size - 1); dest[size - 1] = '\0'; return dest; }