Commit cc4fd506 by Serge Hallyn Committed by Stéphane Graber

lxc_mount_auto_mounts: fix weirdness

The default_mounts[i].destination is never NULL except in the last 'stop here' entry. Coverity doesn't know about that and so is spewing a warning. In any case, let's add a more stringent check in case someone accidentally adds a NULL there later. Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 2c79e91b
...@@ -803,7 +803,10 @@ static int lxc_mount_auto_mounts(struct lxc_conf *conf, int flags, struct lxc_ha ...@@ -803,7 +803,10 @@ static int lxc_mount_auto_mounts(struct lxc_conf *conf, int flags, struct lxc_ha
return -1; return -1;
} }
} }
if (default_mounts[i].destination) { if (!default_mounts[i].destination) {
ERROR("BUG: auto mounts destination %d was NULL", i);
return -1;
}
/* will act like strdup if %r is not present */ /* will act like strdup if %r is not present */
destination = lxc_string_replace("%r", conf->rootfs.path ? conf->rootfs.mount : "", default_mounts[i].destination); destination = lxc_string_replace("%r", conf->rootfs.path ? conf->rootfs.mount : "", default_mounts[i].destination);
if (!destination) { if (!destination) {
...@@ -813,7 +816,6 @@ static int lxc_mount_auto_mounts(struct lxc_conf *conf, int flags, struct lxc_ha ...@@ -813,7 +816,6 @@ static int lxc_mount_auto_mounts(struct lxc_conf *conf, int flags, struct lxc_ha
errno = saved_errno; errno = saved_errno;
return -1; return -1;
} }
}
mflags = add_required_remount_flags(source, destination, mflags = add_required_remount_flags(source, destination,
default_mounts[i].flags); default_mounts[i].flags);
r = safe_mount(source, destination, default_mounts[i].fstype, mflags, default_mounts[i].options, conf->rootfs.path ? conf->rootfs.mount : NULL); r = safe_mount(source, destination, default_mounts[i].fstype, mflags, default_mounts[i].options, conf->rootfs.path ? conf->rootfs.mount : NULL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment