]> granicus.if.org Git - sudo/commitdiff
When parsing def_editor, break out of the loop when we find the
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 21 Aug 2015 17:25:02 +0000 (11:25 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 21 Aug 2015 17:25:02 +0000 (11:25 -0600)
first valid editor.  Bug #714

NEWS
plugins/sudoers/sudoers.c
plugins/sudoers/visudo.c

diff --git a/NEWS b/NEWS
index cbe2d8b82e1b64c96ff1bd30f118fd04d426d702..f4cc18a6b40f36893949c6936c613266d26021b2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,10 @@ What's new in Sudo 1.8.15
    enabling the sudoedit_follow option in sudoers or on a per-command
    basis with the FOLLOW and NOFOLLOW tags.  Bug #707.
 
+ * Fixed a bug introduced in versino 1.8.14 that caused the last
+   valid editor in the sudoers "editor" list to be used by visudo
+   and sudoedit instead of the first.  Bug #714.
+
 What's new in Sudo 1.8.14p3
 
  * Fixed a bug introduced in sudo 1.8.14p2 that prevented sudo
index fd5c58f2deb716da9ccab77e776963dff95d6a55..effd22b63698e8a23a6bab9bc529a36334d0dcd3 100644 (file)
@@ -1201,7 +1201,9 @@ find_editor(int nfiles, char **files, int *argc_out, char ***argv_out)
        if ((editor = getenv(*ev)) != NULL && *editor != '\0') {
            editor_path = resolve_editor(editor, strlen(editor),
                nfiles, files, argc_out, argv_out, NULL);
-           if (editor_path == NULL && errno != ENOENT)
+           if (editor_path != NULL)
+               break;
+           if (errno != ENOENT)
                debug_return_str(NULL);
        }
     }
index af0f46779a60b9a1d3181079ad75187d61a33b30..b209fe00e1d3df9f4af691de2585ca731df246b9 100644 (file)
@@ -330,7 +330,9 @@ get_editor(int *editor_argc, char ***editor_argv)
            cp != NULL; cp = sudo_strsplit(NULL, def_editor_end, ":", &ep)) {
            editor_path = resolve_editor(cp, (size_t)(ep - cp), 2, files,
                editor_argc, editor_argv, whitelist);
-           if (editor_path == NULL && errno != ENOENT)
+           if (editor_path != NULL)
+               break;
+           if (errno != ENOENT)
                debug_return_str(NULL);
        }
     }