From: Christian Brauner Date: Fri, 15 Jun 2018 11:36:37 +0000 (+0200) Subject: coverity: #1425855 X-Git-Tag: lxc-2.0.10~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b5710d3c75a019b73e8c8de3a4c61a01d7b90129;p=thirdparty%2Flxc.git coverity: #1425855 String not null terminated Signed-off-by: Christian Brauner --- diff --git a/src/lxc/tools/lxc_info.c b/src/lxc/tools/lxc_info.c index 24ca743a0..8ac71ab46 100644 --- a/src/lxc/tools/lxc_info.c +++ b/src/lxc/tools/lxc_info.c @@ -176,6 +176,7 @@ static void print_net_stats(struct lxc_container *c) snprintf(path, sizeof(path), "/sys/class/net/%s/statistics/rx_bytes", ifname); rc = lxc_read_from_file(path, buf, sizeof(buf)); if (rc > 0) { + buf[rc - 1] = '\0'; str_chomp(buf); rx_bytes = str_size_humanize(buf, sizeof(buf)); printf("%-15s %s\n", " TX bytes:", buf); @@ -185,6 +186,7 @@ static void print_net_stats(struct lxc_container *c) snprintf(path, sizeof(path), "/sys/class/net/%s/statistics/tx_bytes", ifname); rc = lxc_read_from_file(path, buf, sizeof(buf)); if (rc > 0) { + buf[rc - 1] = '\0'; str_chomp(buf); tx_bytes = str_size_humanize(buf, sizeof(buf)); printf("%-15s %s\n", " RX bytes:", buf);