From b954f0bc948c841349d8d8929f2ab2ac5c4f9ce5 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 1 Jun 2004 16:51:06 +0000 Subject: [PATCH] When checking for a command in the directory, only copy the base dir once. --- parse.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/parse.c b/parse.c index 12f6835ca..f8659a915 100644 --- 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 */ -- 2.40.0