From: Christian Brauner Date: Tue, 31 Jul 2018 08:55:52 +0000 (+0200) Subject: coverity: #438136 X-Git-Tag: lxc-2.0.10~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c92a2062f441977f6166e6891a5bbc1905724ce4;p=thirdparty%2Flxc.git coverity: #438136 String not null terminated Signed-off-by: Christian Brauner --- diff --git a/src/lxc/tools/lxc_destroy.c b/src/lxc/tools/lxc_destroy.c index 02f9e25e7..ea5d1eec7 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) 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; }