]> granicus.if.org Git - sudo/commitdiff
When checking for a command in the directory, only copy the base dir once.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 1 Jun 2004 16:51:06 +0000 (16:51 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 1 Jun 2004 16:51:06 +0000 (16:51 +0000)
parse.c

diff --git a/parse.c b/parse.c
index 12f6835cadde7abfe144c3d439abd17c9258c340..f8659a915cfaa9f985f38b531338147be3b739c5 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -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 */