]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
coverity: #1425855
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 15 Jun 2018 11:36:37 +0000 (13:36 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 10 Dec 2018 08:25:41 +0000 (09:25 +0100)
String not null terminated

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

index 24ca743a0e8585259cc082e33558532ed70e3fa6..8ac71ab46bdba607d1a9f2760eb88ddac985233f 100644 (file)
@@ -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);