From: Paul Romlow Date: Wed, 5 Jun 2019 18:28:21 +0000 (-0500) Subject: proposed fix for #2892 - fix lxcbasename in lxc/lxccontainer.c X-Git-Tag: lxc-3.2.0~35^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85e02f56000be3bc41859a15ccac7c57c3baf92b;p=thirdparty%2Flxc.git proposed fix for #2892 - fix lxcbasename in lxc/lxccontainer.c Signed-off-by: Paul Romlow --- diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index 9dbc6e022..253f07f68 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -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;