add-remove-shell: fix crash when shell is already added
authorTimo Teräs <timo.teras@iki.fi>
Fri, 14 Jul 2017 07:59:52 +0000 (09:59 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 14 Jul 2017 07:59:52 +0000 (09:59 +0200)
Avoid dereferencing 'don_add' in strcmp since it is invalid
pointer.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
loginutils/add-remove-shell.c

index 922b3333d43d7a06c841ec6aa00c015727068f22..54b62c7731b9b964eebeae88e6c303311acf2ba4 100644 (file)
@@ -84,7 +84,7 @@ int add_remove_shell_main(int argc UNUSED_PARAM, char **argv)
                while ((line = xmalloc_fgetline(orig_fp)) != NULL) {
                        char **cpp = argv;
                        while (*cpp) {
-                               if (strcmp(*cpp, line) == 0) {
+                               if (*cpp != dont_add && strcmp(*cpp, line) == 0) {
                                        /* Old file has this shell name */
                                        if (REMOVE_SHELL) {
                                                /* we are remove-shell */