From: Todd C. Miller Date: Tue, 15 Sep 2015 15:29:40 +0000 (-0600) Subject: We reserved two slots at the end of the editor argv for the line X-Git-Tag: SUDO_1_8_15^2~51 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b6cb1b65c9168dc7ff05d093687d0c1fd7775a94;p=sudo We reserved two slots at the end of the editor argv for the line number and the file name. However, resolve_editor() adds "--" before the file names so the +line_number is interpreted as a file name, not a line number so we need to overwrite the "--" as well. --- diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c index 5bde49aa2..155de7c1c 100644 --- a/plugins/sudoers/visudo.c +++ b/plugins/sudoers/visudo.c @@ -465,14 +465,15 @@ edit_sudoers(struct sudoersfile *sp, char *editor, int editor_argc, lineno = -1; /* - * We pre-allocated 2 extra spaces for "+n filename" in argv. + * The last 3 slots in the editor argv are: "-- +1 sudoers" * Replace those placeholders with the real values. */ - ac = editor_argc - 2; + ac = editor_argc - 3; if (lineno > 0) { (void)snprintf(linestr, sizeof(linestr), "+%d", lineno); editor_argv[ac++] = linestr; } + editor_argv[ac++] = "--"; editor_argv[ac++] = sp->tpath; editor_argv[ac++] = NULL;