String not null terminated

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2018-07-31 10:55:52 +02:00
parent 8da51ee9b3
commit aeba3f8005
No known key found for this signature in database
GPG Key ID: 8EB056D53EECB12D

View File

@ -211,6 +211,7 @@ static bool do_destroy_with_snapshots(struct lxc_container *c)
char *lxcname = NULL; char *lxcname = NULL;
int fd; int fd;
int ret; int ret;
ssize_t bytes;
/* Destroy clones. */ /* Destroy clones. */
ret = snprintf(path, MAXPATHLEN, "%s/%s/lxc_snapshots", c->config_path, c->name); 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; return false;
} }
ret = lxc_read_nointr(fd, buf, fbuf.st_size); bytes = lxc_read_nointr(fd, buf, fbuf.st_size);
close(fd); close(fd);
if (ret < 0) { if (bytes != (ssize_t)fbuf.st_size) {
ERROR("Could not read %s", path); ERROR("Could not read %s", path);
free(buf); free(buf);
return false; return false;