From: Todd C. Miller Date: Tue, 1 Jun 2004 16:51:06 +0000 (+0000) Subject: When checking for a command in the directory, only copy the base dir once. X-Git-Tag: SUDO_1_6_8~96 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b954f0bc948c841349d8d8929f2ab2ac5c4f9ce5;p=sudo When checking for a command in the directory, only copy the base dir once. --- 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 */