diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-07 15:50:30 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-07 15:50:30 +0200 |
commit | 17058a06c4333fc0c492c168c8a971ebd0fd5a5a (patch) | |
tree | a32133b2e5c18be65796283177551f9bcd7e49bb /loginutils | |
parent | bae8fc4436f9aeb43ef0aaccd1c9b1b35b5a4617 (diff) | |
download | busybox-w32-17058a06c4333fc0c492c168c8a971ebd0fd5a5a.tar.gz busybox-w32-17058a06c4333fc0c492c168c8a971ebd0fd5a5a.tar.bz2 busybox-w32-17058a06c4333fc0c492c168c8a971ebd0fd5a5a.zip |
libbb: switch bb_ask_noecho() to "mallocing" string return API
function old new delta
bb_ask_noecho 313 330 +17
get_cred_or_die 125 115 -10
passwd_main 995 958 -37
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 17/-47) Total: -30 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'loginutils')
-rw-r--r-- | loginutils/cryptpw.c | 2 | ||||
-rw-r--r-- | loginutils/passwd.c | 3 |
2 files changed, 2 insertions, 3 deletions
diff --git a/loginutils/cryptpw.c b/loginutils/cryptpw.c index 3ca7eda4a..fbb7f0515 100644 --- a/loginutils/cryptpw.c +++ b/loginutils/cryptpw.c | |||
@@ -133,7 +133,7 @@ int cryptpw_main(int argc UNUSED_PARAM, char **argv) | |||
133 | if (!password) { | 133 | if (!password) { |
134 | /* Only mkpasswd, and only from tty, prompts. | 134 | /* Only mkpasswd, and only from tty, prompts. |
135 | * Otherwise it is a plain read. */ | 135 | * Otherwise it is a plain read. */ |
136 | password = (ENABLE_MKPASSWD && isatty(STDIN_FILENO) && applet_name[0] == 'm') | 136 | password = (ENABLE_MKPASSWD && applet_name[0] == 'm' && isatty(STDIN_FILENO)) |
137 | ? bb_ask_noecho_stdin("Password: ") | 137 | ? bb_ask_noecho_stdin("Password: ") |
138 | : xmalloc_fgetline(stdin) | 138 | : xmalloc_fgetline(stdin) |
139 | ; | 139 | ; |
diff --git a/loginutils/passwd.c b/loginutils/passwd.c index 02303b575..d0408d8b4 100644 --- a/loginutils/passwd.c +++ b/loginutils/passwd.c | |||
@@ -65,11 +65,9 @@ static char* new_password(const struct passwd *pw, uid_t myuid, const char *algo | |||
65 | if (ENABLE_FEATURE_CLEAN_UP) | 65 | if (ENABLE_FEATURE_CLEAN_UP) |
66 | free(encrypted); | 66 | free(encrypted); |
67 | } | 67 | } |
68 | orig = xstrdup(orig); /* or else bb_ask_noecho_stdin() will destroy it */ | ||
69 | newp = bb_ask_noecho_stdin("New password: "); /* returns ptr to static */ | 68 | newp = bb_ask_noecho_stdin("New password: "); /* returns ptr to static */ |
70 | if (!newp) | 69 | if (!newp) |
71 | goto err_ret; | 70 | goto err_ret; |
72 | newp = xstrdup(newp); /* we are going to bb_ask_noecho_stdin() again, so save it */ | ||
73 | if (ENABLE_FEATURE_PASSWD_WEAK_CHECK | 71 | if (ENABLE_FEATURE_PASSWD_WEAK_CHECK |
74 | && obscure(orig, newp, pw) | 72 | && obscure(orig, newp, pw) |
75 | && myuid != 0 | 73 | && myuid != 0 |
@@ -99,6 +97,7 @@ static char* new_password(const struct passwd *pw, uid_t myuid, const char *algo | |||
99 | if (ENABLE_FEATURE_CLEAN_UP) free(newp); | 97 | if (ENABLE_FEATURE_CLEAN_UP) free(newp); |
100 | 98 | ||
101 | nuke_str(cp); | 99 | nuke_str(cp); |
100 | if (ENABLE_FEATURE_CLEAN_UP) free(cp); | ||
102 | return ret; | 101 | return ret; |
103 | } | 102 | } |
104 | 103 | ||