2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 14:25:15 +00:00

When checking for a command in the directory, only copy the base dir once.

This commit is contained in:
Todd C. Miller
2004-06-01 16:51:06 +00:00
parent e2a573d6cc
commit b954f0bc94

View File

@@ -349,10 +349,12 @@ command_matches(cmnd, cmnd_args, path, sudoers_args)
if (dirp == NULL)
return(FALSE);
if (strlcpy(buf, path, sizeof(buf)) >= sizeof(buf))
return(FALSE);
while ((dent = readdir(dirp)) != NULL) {
/* ignore paths > PATH_MAX (XXX - log) */
if (strlcpy(buf, path, sizeof(buf)) >= sizeof(buf) ||
strlcat(buf, dent->d_name, sizeof(buf)) >= sizeof(buf))
buf[plen] = '\0';
if (strlcat(buf, dent->d_name, sizeof(buf)) >= sizeof(buf))
continue;
/* only stat if basenames are the same */