Fix dirname calls in runscript
runscript will try to get the dir and basename of a file/link in case it contains at least one slash. This patch gives a temporary copy of the path to the dirname() function since dirname() can modify its argument.
This commit is contained in:
parent
74c8667497
commit
d59e245bc7
@ -1101,7 +1101,8 @@ runscript(int argc, char **argv)
|
|||||||
bool doneone = false;
|
bool doneone = false;
|
||||||
int retval, opt, depoptions = RC_DEP_TRACE;
|
int retval, opt, depoptions = RC_DEP_TRACE;
|
||||||
RC_STRING *svc;
|
RC_STRING *svc;
|
||||||
char path[PATH_MAX], lnk[PATH_MAX], *dir, *save = NULL, pidstr[10];
|
char path[PATH_MAX], lnk[PATH_MAX], *dir, *save = NULL, *save2 = NULL;
|
||||||
|
char pidstr[10];
|
||||||
size_t l = 0, ll;
|
size_t l = 0, ll;
|
||||||
const char *file;
|
const char *file;
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
@ -1133,7 +1134,8 @@ runscript(int argc, char **argv)
|
|||||||
dir = dirname(path);
|
dir = dirname(path);
|
||||||
if (strchr(lnk, '/')) {
|
if (strchr(lnk, '/')) {
|
||||||
save = xstrdup(dir);
|
save = xstrdup(dir);
|
||||||
dir = dirname(lnk);
|
save2 = xstrdup(lnk);
|
||||||
|
dir = dirname(save2);
|
||||||
if (strcmp(dir, save) == 0)
|
if (strcmp(dir, save) == 0)
|
||||||
file = basename_c(argv[1]);
|
file = basename_c(argv[1]);
|
||||||
else
|
else
|
||||||
@ -1149,6 +1151,7 @@ runscript(int argc, char **argv)
|
|||||||
service = xstrdup(lnk);
|
service = xstrdup(lnk);
|
||||||
}
|
}
|
||||||
free(save);
|
free(save);
|
||||||
|
free(save2);
|
||||||
}
|
}
|
||||||
if (!service)
|
if (!service)
|
||||||
service = xstrdup(path);
|
service = xstrdup(path);
|
||||||
|
Loading…
Reference in New Issue
Block a user