add-remove-shell: fix crash when shell is already added

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>
This commit is contained in:
Timo Teräs 2017-07-14 09:59:52 +02:00 committed by Denys Vlasenko
parent a2bdc5c554
commit cc86b2ad96

View 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 */