1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
--- a/loginutils/chpasswd.c
+++ b/loginutils/chpasswd.c
@@ -97,6 +97,11 @@ int chpasswd_main(int argc UNUSED_PARAM,
crypt_make_pw_salt(salt, algo);
free_me = pass = pw_encrypt(pass, salt, 0);
+
+ if (pass[0] == 0) {
+ free(free_me);
+ bb_perror_msg_and_die("password encryption failed");
+ }
}
/* This is rather complex: if user is not found in /etc/shadow,
--- a/loginutils/cryptpw.c
+++ b/loginutils/cryptpw.c
@@ -95,7 +95,7 @@ int cryptpw_main(int argc UNUSED_PARAM,
/* Supports: cryptpw -m sha256 PASS 'rounds=999999999$SALT' */
char salt[MAX_PW_SALT_LEN + sizeof("rounds=999999999$")];
char *salt_ptr;
- char *password;
+ char *password, *hash;
const char *opt_m, *opt_S;
int fd;
@@ -140,8 +140,12 @@ int cryptpw_main(int argc UNUSED_PARAM,
/* may still be NULL on EOF/error */
}
- if (password)
- puts(pw_encrypt(password, salt, 1));
+ if (password) {
+ hash = pw_encrypt(password, salt, 1);
+ if (hash[0] == 0)
+ bb_perror_msg_and_die("password encryption failed");
+ puts(hash);
+ }
return EXIT_SUCCESS;
}
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -187,6 +187,10 @@ int passwd_main(int argc UNUSED_PARAM, c
if (!newp) {
logmode = LOGMODE_STDIO;
bb_error_msg_and_die("password for %s is unchanged", name);
+ } else if (newp[0] == 0) {
+ logmode = LOGMODE_STDIO;
+ free(newp);
+ bb_perror_msg_and_die("password encryption failed");
}
} else if (opt & OPT_lock) {
if (!c)
|