[PATCH] add-remove-shell: fix crash when shell is already added
Timo Teräs
timo.teras at iki.fi
Fri Jul 14 06:12:35 UTC 2017
Avoid dereferencing 'don_add' in strcmp since it is invalid
pointer.
Signed-off-by: Timo Teräs <timo.teras at iki.fi>
---
Please include in -fixes for v1.27.0
loginutils/add-remove-shell.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/loginutils/add-remove-shell.c b/loginutils/add-remove-shell.c
index 922b3333d..54b62c773 100644
--- a/loginutils/add-remove-shell.c
+++ b/loginutils/add-remove-shell.c
@@ -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 */
--
2.13.2
More information about the busybox
mailing list