LibC: Fix exec family function path resolution
This commit is contained in:
parent
3be17c6117
commit
163fdcd582
|
@ -231,13 +231,13 @@ static int exec_impl(const char* pathname, char* const* argv, char* const* envp,
|
||||||
while (*cur)
|
while (*cur)
|
||||||
{
|
{
|
||||||
const char* end = strchrnul(cur, ':');
|
const char* end = strchrnul(cur, ':');
|
||||||
size_t len = end - cur;
|
const size_t len = end - cur;
|
||||||
|
|
||||||
ASSERT(strlen(pathname) + 1 + len < sizeof(buffer));
|
ASSERT(strlen(pathname) + 1 + len < sizeof(buffer));
|
||||||
|
|
||||||
strncpy(buffer, cur, len);
|
memcpy(buffer, cur, len);
|
||||||
strcat(buffer, "/");
|
buffer[len] = '/';
|
||||||
strcat(buffer, pathname);
|
strcpy(buffer + len + 1, pathname);
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(buffer, &st) == 0)
|
if (stat(buffer, &st) == 0)
|
||||||
|
|
Loading…
Reference in New Issue