]> granicus.if.org Git - sudo/commitdiff
Close dir before returning if strlcpy() reports overflow.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 7 Aug 2009 13:25:22 +0000 (13:25 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 7 Aug 2009 13:25:22 +0000 (13:25 +0000)
From Martynas Venckus.

match.c

diff --git a/match.c b/match.c
index 269861d7c91fe0aa53469f99a4a03348a04ba139..8d80085cd9e11a79605d410c2269dd822c9b693e 100644 (file)
--- a/match.c
+++ b/match.c
@@ -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';