From: Christian Brauner Date: Sun, 24 Sep 2017 11:58:57 +0000 (+0200) Subject: storage: avoid segfault X-Git-Tag: lxc-2.0.9~14^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7dd79097de8d2b9ec3ec133bf7f1f9eada6fa7e;p=thirdparty%2Flxc.git 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: Christian Brauner --- diff --git a/src/lxc/storage/storage.c b/src/lxc/storage/storage.c index 820fd2407..90053152e 100644 --- a/src/lxc/storage/storage.c +++ b/src/lxc/storage/storage.c @@ -312,9 +312,14 @@ struct lxc_storage *storage_copy(struct lxc_container *c0, const char *cname, const char *oldpath = c0->config_path; struct rsync_data data; - /* if the container name doesn't show up in the rootfs path, then - * we don't know how to come up with a new name + /* If the container name doesn't show up in the rootfs path, then we + * don't know how to come up with a new name. */ + if (!src) { + ERROR("No rootfs specified"); + return NULL; + } + if (strstr(src, oldname) == NULL) { ERROR( "original rootfs path %s doesn't include container name %s",