]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
proposed fix for #2892 - fix lxcbasename in lxc/lxccontainer.c 3032/head
authorPaul Romlow <paul@romlow.com>
Wed, 5 Jun 2019 18:28:21 +0000 (13:28 -0500)
committerPaul Romlow <paul@romlow.com>
Wed, 5 Jun 2019 18:28:21 +0000 (13:28 -0500)
Signed-off-by: Paul Romlow <paul@romlow.com>
src/lxc/lxccontainer.c

index 9dbc6e022f7462579aec17277932cb945c7631e3..253f07f68316f518e0a8b2381c0aef7627f028d4 100644 (file)
@@ -1320,12 +1320,13 @@ static struct lxc_storage *do_storage_create(struct lxc_container *c,
        return bdev;
 }
 
-static char *lxcbasename(char *path)
+/* Strip path and return name of file for argv[0] passed to execvp */
+static char *lxctemplatefilename(char *tpath)
 {
        char *p;
 
-       p = path + strlen(path) - 1;
-       while (*p != '/' && p > path)
+       p = tpath + strlen(tpath) - 1;
+       while ( (p-1) >= tpath && *(p-1) != '/')
                p--;
 
        return p;
@@ -1451,7 +1452,7 @@ static bool create_run_template(struct lxc_container *c, char *tpath,
                newargv = malloc(nargs * sizeof(*newargv));
                if (!newargv)
                        _exit(EXIT_FAILURE);
-               newargv[0] = lxcbasename(tpath);
+               newargv[0] = lxctemplatefilename(tpath);
 
                /* --path */
                len = strlen(c->config_path) + strlen(c->name) + strlen("--path=") + 2;