]> 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>
Fri, 15 Jun 2018 11:47:20 +0000 (13:47 +0200)
String not null terminated

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

index 16d60f48da71b895219af6268806b95ea6064fce..09889e31e92ffbebead25db5a0bf86dad8f618d1 100644 (file)
@@ -178,6 +178,7 @@ static void print_net_stats(struct lxc_container *c)
 
                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);
@@ -190,6 +191,7 @@ static void print_net_stats(struct lxc_container *c)
 
                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);