LibC: Fix exec family function path resolution

This commit is contained in:
Bananymous 2025-07-15 11:44:14 +03:00
parent 3be17c6117
commit 163fdcd582
1 changed files with 4 additions and 4 deletions

View File

@ -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)