From: Todd C. Miller Date: Sun, 19 Apr 2009 12:56:42 +0000 (+0000) Subject: Ignore files ending in '~' in sudo.d (emacs backup files) X-Git-Tag: SUDO_1_7_2~44 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=72a1d82412a304fc3bacbd1450aac6fcc1444619;p=sudo Ignore files ending in '~' in sudo.d (emacs backup files) --- diff --git a/toke.c b/toke.c index 955c2e1fa..dd4c67675 100644 --- a/toke.c +++ b/toke.c @@ -3258,9 +3258,11 @@ switch_dir(stack, dirpath) return(FALSE); } while ((dent = readdir(dir))) { - /* Ignore files that have a '.' in them. */ - if (strchr(dent->d_name, '.') != NULL) + /* Ignore files that end in '~' or have a '.' in them. */ + if (dent->d_namlen == 0 || dent->d_name[dent->d_namlen - 1] == '~' + || strchr(dent->d_name, '.') != NULL) { continue; + } if (asprintf(&path, "%s/%s", dirpath, dent->d_name) == -1) { closedir(dir); goto bad; diff --git a/toke.l b/toke.l index 6a604a885..cc18cec9c 100644 --- a/toke.l +++ b/toke.l @@ -663,9 +663,11 @@ switch_dir(stack, dirpath) return(FALSE); } while ((dent = readdir(dir))) { - /* Ignore files that have a '.' in them. */ - if (strchr(dent->d_name, '.') != NULL) + /* Ignore files that end in '~' or have a '.' in them. */ + if (dent->d_namlen == 0 || dent->d_name[dent->d_namlen - 1] == '~' + || strchr(dent->d_name, '.') != NULL) { continue; + } if (asprintf(&path, "%s/%s", dirpath, dent->d_name) == -1) { closedir(dir); goto bad;