]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
vipw: don't modify environment, check strtok() return value
authorKarel Zak <kzak@redhat.com>
Wed, 1 Feb 2012 11:41:25 +0000 (12:41 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 1 Feb 2012 11:41:25 +0000 (12:41 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/vipw.c

index 4dfcfce9e917bd04ba9df8ffda43cec74f407248..1926db8c815c5be29c108923f0f50070d07f8585 100644 (file)
@@ -215,11 +215,13 @@ static void pw_edit(int notsetuid)
 {
        int pstat;
        pid_t pid;
-       char *p, *editor;
+       char *p, *editor, *tk;
 
-       if (!(editor = getenv("EDITOR")))
-               editor = strdup(_PATH_VI);      /* adia@egnatia.ee.auth.gr */
-       if ((p = strrchr(strtok(editor, " \t"), '/')) != NULL)
+       editor = getenv("EDITOR");
+       editor = strdup(editor ? editor : _PATH_VI);
+
+       tk = strtok(editor, " \t");
+       if (tk && (p = strrchr(tk, '/')) != NULL)
                ++p;
        else
                p = editor;