[lxc-devel] [lxc/master] coverity: #438136

brauner on Github lxc-bot at linuxcontainers.org
Tue Jul 31 08:56:50 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 394 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180731/1b3884d7/attachment.bin>
-------------- next part --------------
From aeba3f80050bb50385eac679c2dc1ffb0302ef62 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 31 Jul 2018 10:55:52 +0200
Subject: [PATCH] coverity: #438136

String not null terminated

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/tools/lxc_destroy.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/lxc/tools/lxc_destroy.c b/src/lxc/tools/lxc_destroy.c
index e208cf6fd..90e53daa7 100644
--- a/src/lxc/tools/lxc_destroy.c
+++ b/src/lxc/tools/lxc_destroy.c
@@ -211,6 +211,7 @@ static bool do_destroy_with_snapshots(struct lxc_container *c)
 	char *lxcname = NULL;
 	int fd;
 	int ret;
+	ssize_t bytes;
 
 	/* Destroy clones. */
 	ret = snprintf(path, MAXPATHLEN, "%s/%s/lxc_snapshots", c->config_path, c->name);
@@ -233,9 +234,9 @@ static bool do_destroy_with_snapshots(struct lxc_container *c)
 			return false;
 		}
 
-		ret = lxc_read_nointr(fd, buf, fbuf.st_size);
+		bytes = lxc_read_nointr(fd, buf, fbuf.st_size);
 		close(fd);
-		if (ret < 0) {
+		if (bytes != (ssize_t)fbuf.st_size) {
 			ERROR("Could not read %s", path);
 			free(buf);
 			return false;


More information about the lxc-devel mailing list