storage: avoid segfault

When the "lxc.rootfs.path" property is not set and users request a container copy we would segfault since strstr() would be called on a NULL pointer. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent f17ddbee
...@@ -312,9 +312,14 @@ struct lxc_storage *storage_copy(struct lxc_container *c0, const char *cname, ...@@ -312,9 +312,14 @@ struct lxc_storage *storage_copy(struct lxc_container *c0, const char *cname,
const char *oldpath = c0->config_path; const char *oldpath = c0->config_path;
struct rsync_data data; struct rsync_data data;
/* if the container name doesn't show up in the rootfs path, then /* If the container name doesn't show up in the rootfs path, then we
* we don't know how to come up with a new name * don't know how to come up with a new name.
*/ */
if (!src) {
ERROR("No rootfs specified");
return NULL;
}
if (strstr(src, oldname) == NULL) { if (strstr(src, oldname) == NULL) {
ERROR( ERROR(
"original rootfs path %s doesn't include container name %s", "original rootfs path %s doesn't include container name %s",
......
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