]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
storage: avoid segfault
authorChristian Brauner <christian.brauner@ubuntu.com>
Sun, 24 Sep 2017 11:58:57 +0000 (13:58 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 24 Sep 2017 12:10:14 +0000 (14:10 +0200)
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 <christian.brauner@ubuntu.com>
src/lxc/storage/storage.c

index 820fd24078e143b84f98a11a1d75c14f0bc5ec9c..90053152ed55fcb3a2f0600f374df1b075529382 100644 (file)
@@ -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",