From 333faa20e21bf66a7b7a28a450a73f0eca3cf4ee Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 21 Aug 2015 11:25:02 -0600 Subject: [PATCH] When parsing def_editor, break out of the loop when we find the first valid editor. Bug #714 --- NEWS | 4 ++++ plugins/sudoers/sudoers.c | 4 +++- plugins/sudoers/visudo.c | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index cbe2d8b82..f4cc18a6b 100644 --- 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 diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index fd5c58f2d..effd22b63 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -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); } } diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c index af0f46779..b209fe00e 100644 --- a/plugins/sudoers/visudo.c +++ b/plugins/sudoers/visudo.c @@ -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); } } -- 2.40.0