libbb: don't die if crypt() returns NULL
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
4e03d41342
commit
8ed9672660
@ -142,7 +142,14 @@ char* FAST_FUNC pw_encrypt(const char *clear, const char *salt, int cleanup)
|
||||
|
||||
char* FAST_FUNC pw_encrypt(const char *clear, const char *salt, int cleanup)
|
||||
{
|
||||
return xstrdup(crypt(clear, salt));
|
||||
char *s;
|
||||
|
||||
s = crypt(clear, salt);
|
||||
/*
|
||||
* glibc used to return "" on malformed salts (for example, ""),
|
||||
* but since 2.17 it returns NULL.
|
||||
*/
|
||||
return xstrdup(s ? s : "");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user