]> granicus.if.org Git - sudo/commitdiff
We reserved two slots at the end of the editor argv for the line
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 15 Sep 2015 15:29:40 +0000 (09:29 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 15 Sep 2015 15:29:40 +0000 (09:29 -0600)
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.

plugins/sudoers/visudo.c

index 5bde49aa2b8f5e0371b16b710ab29643301aa7db..155de7c1c55e000c11c1950effb629b32bb8c77c 100644 (file)
@@ -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;