[lxc-devel] [lxc/master] conf: check for successful mount entry parse
brauner on Github
lxc-bot at linuxcontainers.org
Sun Jan 27 01:24:36 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 511 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190126/62115862/attachment.bin>
-------------- next part --------------
From 56e404e7588a936d41cea406c539fd29aec4e9e8 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sun, 27 Jan 2019 02:22:43 +0100
Subject: [PATCH] conf: check for successful mount entry parse
Since liblxc is completely in control of the mount entry file we should
only consider a parse successful when EOF is reached.
Closes #2798.
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/conf.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 6b2ebf7ec6..0fd1e85b5a 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -2336,11 +2336,12 @@ static int mount_file_entries(const struct lxc_conf *conf,
const struct lxc_rootfs *rootfs, FILE *file,
const char *lxc_name, const char *lxc_path)
{
- char buf[4096];
+ char buf[PATH_MAX];
struct mntent mntent;
- int ret = -1;
while (getmntent_r(file, &mntent, buf, sizeof(buf))) {
+ int ret;
+
if (!rootfs->path)
ret = mount_entry_on_systemfs(&mntent);
else if (mntent.mnt_dir[0] != '/')
@@ -2348,14 +2349,17 @@ static int mount_file_entries(const struct lxc_conf *conf,
lxc_name, lxc_path);
else
ret = mount_entry_on_absolute_rootfs(&mntent, rootfs,
- lxc_name, lxc_path);
+ lxc_name, lxc_path);
if (ret < 0)
return -1;
}
- ret = 0;
- INFO("Finished setting up mounts");
- return ret;
+ if (!feof(file)) {
+ ERROR("Failed to parse mount entries");
+ return -1;
+ }
+
+ return 0;
}
static int setup_mount(const struct lxc_conf *conf,
More information about the lxc-devel
mailing list