]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
coverity: #438136 2505/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 31 Jul 2018 08:55:52 +0000 (10:55 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 31 Jul 2018 08:55:52 +0000 (10:55 +0200)
String not null terminated

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

index e208cf6fd42d40a8f4ffac78760225bac7d08756..90e53daa73b5ad07ffe8c3410cf2cc51f88670f7 100644 (file)
@@ -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;