visudo, EDITOR, Defaults (editor)

Todd C. Miller Todd.Miller at courtesan.com
Thu Jan 17 10:36:43 EST 2002


Try the following patch.

 - todd

Index: visudo.c
===================================================================
RCS file: /home/cvs-sudo/sudo/visudo.c,v
retrieving revision 1.145
retrieving revision 1.146
diff -u -r1.145 -r1.146
--- visudo.c	14 Dec 2001 19:52:48 -0000	1.145
+++ visudo.c	17 Jan 2002 15:35:54 -0000	1.146
@@ -277,7 +277,7 @@
      * See if we can use the user's choice of editors either because
      * we allow any $EDITOR or because $EDITOR is in the allowable list.
      */
-    Editor = NULL;
+    Editor = EditorPath = NULL;
     if (def_flag(I_ENV_EDITOR) && UserEditor)
 	Editor = UserEditor;
     else if (UserEditor) {
@@ -318,7 +318,6 @@
 		    break;
 	    }
 	} while ((Editor = strtok(NULL, ":")));
-	free(EditorPath);
     }
 
     /*
@@ -326,6 +325,8 @@
      * find one that exists, is regular, and is executable.
      */
     if (Editor == NULL || *Editor == '\0') {
+	if (EditorPath != NULL)
+	    free(EditorPath);
 	EditorPath = estrdup(def_str(I_EDITOR));
 	Editor = strtok(EditorPath, ":");
 	do {



More information about the sudo-users mailing list