2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-30 05:48:18 +00:00

Close dir before returning if strlcpy() reports overflow.

From Martynas Venckus.
This commit is contained in:
Todd C. Miller 2009-08-07 13:25:22 +00:00
parent ee20527bf0
commit fde79c46fb

View File

@ -580,8 +580,10 @@ command_matches_dir(sudoers_dir, dlen)
if (dirp == NULL)
return(FALSE);
if (strlcpy(buf, sudoers_dir, sizeof(buf)) >= sizeof(buf))
if (strlcpy(buf, sudoers_dir, sizeof(buf)) >= sizeof(buf)) {
closedir(dirp);
return(FALSE);
}
while ((dent = readdir(dirp)) != NULL) {
/* ignore paths > PATH_MAX (XXX - log) */
buf[dlen] = '\0';