[git commit] adduser: fix a bug of getpwnam() overwriting shell name, closes 8586

Denys Vlasenko vda.linux at googlemail.com
Sat Jan 12 10:51:58 UTC 2019


commit: https://git.busybox.net/busybox/commit/?id=b67d900395a847e29f2afa81198f783004c80fc5
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 loginutils/adduser.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index b2b5be5b3..850c810c4 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -198,7 +198,7 @@ int adduser_main(int argc UNUSED_PARAM, char **argv)
 
 	pw.pw_gecos = (char *)"Linux User,,,";
 	/* We assume that newly created users "inherit" root's shell setting */
-	pw.pw_shell = (char *)get_shell_name();
+	pw.pw_shell = xstrdup(get_shell_name()); /* might come from getpwnam(), need to make a copy */
 	pw.pw_dir = NULL;
 
 	opts = getopt32long(argv, "^"


More information about the busybox-cvs mailing list