From: Ruben Kerkhof Date: Fri, 14 Dec 2018 16:27:44 +0000 (+0100) Subject: libcollectdclient: fix gcc warning X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=28c83da870b4df4a311a5ef20a5ca37d3c84c638;p=collectd.git libcollectdclient: fix gcc warning make[1]: Entering directory '/home/ruben/src/collectd' CC src/libcollectdclient/libcollectdclient_la-network_parse.lo In function ‘parse_string’, inlined from ‘parse_identifier’ at src/libcollectdclient/network_parse.c:169:7, inlined from ‘network_parse.constprop’ at src/libcollectdclient/network_parse.c:540:11: src/libcollectdclient/network_parse.c:161:3: warning: ‘strncpy’ specified bound 64 equals destination size [-Wstringop-truncation] strncpy(out, in, out_size); ^~~~~~~~~~~~~~~~~~~~~~~~~~ --- diff --git a/src/libcollectdclient/network_parse.c b/src/libcollectdclient/network_parse.c index 73476fb7..14e8be57 100644 --- a/src/libcollectdclient/network_parse.c +++ b/src/libcollectdclient/network_parse.c @@ -158,7 +158,8 @@ static int parse_string(void *payload, size_t payload_size, char *out, (payload_size > out_size)) return EINVAL; - strncpy(out, in, out_size); + strncpy(out, in, out_size - 1); + out[out_size - 1] = '\0'; return 0; }