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

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

index 02f9e25e727ec2a507069a58f57333d75bd92105..ea5d1eec7072d0149daf3ffce2c96051bb503d0d 100644 (file)
@@ -211,6 +211,7 @@ static bool do_destroy_with_snapshots(struct lxc_container *c)
        int fd;
        int ret;
        int counter = 0;
+       ssize_t bytes;
 
        /* Destroy clones. */
        ret = snprintf(path, MAXPATHLEN, "%s/%s/lxc_snapshots", c->config_path, c->name);
@@ -233,10 +234,10 @@ static bool do_destroy_with_snapshots(struct lxc_container *c)
                        return false;
                }
 
-               ret = read(fd, buf, fbuf.st_size);
-               if (ret < 0) {
-                       fprintf(stderr, "could not read %s\n", path);
-                       close(fd);
+               bytes = lxc_read_nointr(fd, buf, fbuf.st_size);
+               close(fd);
+               if (bytes != (ssize_t)fbuf.st_size) {
+                       fprintf(stderr, "Could not read %s", path);
                        free(buf);
                        return false;
                }