diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2014-02-09 14:38:03 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2014-02-09 14:38:03 +0100 |
commit | 8ed96726603a59969b99e4ea30dbd9b06955084b (patch) | |
tree | 6e9a14154a4ee84e41d195dcd636a1e65e651b9d | |
parent | 4e03d4134202b117a29ecf5933a7a55e2a8532a4 (diff) | |
download | busybox-w32-8ed96726603a59969b99e4ea30dbd9b06955084b.tar.gz busybox-w32-8ed96726603a59969b99e4ea30dbd9b06955084b.tar.bz2 busybox-w32-8ed96726603a59969b99e4ea30dbd9b06955084b.zip |
libbb: don't die if crypt() returns NULL
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | libbb/pw_encrypt.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libbb/pw_encrypt.c b/libbb/pw_encrypt.c index 39ffa084f..bfc7030a8 100644 --- a/libbb/pw_encrypt.c +++ b/libbb/pw_encrypt.c | |||
@@ -142,7 +142,14 @@ char* FAST_FUNC pw_encrypt(const char *clear, const char *salt, int cleanup) | |||
142 | 142 | ||
143 | char* FAST_FUNC pw_encrypt(const char *clear, const char *salt, int cleanup) | 143 | char* FAST_FUNC pw_encrypt(const char *clear, const char *salt, int cleanup) |
144 | { | 144 | { |
145 | return xstrdup(crypt(clear, salt)); | 145 | char *s; |
146 | |||
147 | s = crypt(clear, salt); | ||
148 | /* | ||
149 | * glibc used to return "" on malformed salts (for example, ""), | ||
150 | * but since 2.17 it returns NULL. | ||
151 | */ | ||
152 | return xstrdup(s ? s : ""); | ||
146 | } | 153 | } |
147 | 154 | ||
148 | #endif | 155 | #endif |