(execvp): Correct copying of file name.
This commit is contained in:
parent
a41301f038
commit
69c0500a4f
|
@ -79,6 +79,7 @@ execvp (file, argv)
|
||||||
int got_eacces = 0;
|
int got_eacces = 0;
|
||||||
char *path, *p, *name;
|
char *path, *p, *name;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
size_t pathlen;
|
||||||
|
|
||||||
path = getenv ("PATH");
|
path = getenv ("PATH");
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
|
@ -93,9 +94,10 @@ execvp (file, argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strlen (file) + 1;
|
len = strlen (file) + 1;
|
||||||
name = __alloca (strlen (path) + len + 1);
|
pathlen = strlen (path);
|
||||||
|
name = __alloca (pathlen + len + 1);
|
||||||
/* Copy the file name at the top. */
|
/* Copy the file name at the top. */
|
||||||
name = (char *) memcpy (name - len, file, len);
|
name = (char *) memcpy (name + pathlen + 1, file, len);
|
||||||
/* And add the slash. */
|
/* And add the slash. */
|
||||||
*--name = '/';
|
*--name = '/';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue