From 8ed96726603a59969b99e4ea30dbd9b06955084b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 9 Feb 2014 14:38:03 +0100 Subject: libbb: don't die if crypt() returns NULL Signed-off-by: Denys Vlasenko --- libbb/pw_encrypt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libbb/pw_encrypt.c') diff --git a/libbb/pw_encrypt.c b/libbb/pw_encrypt.c index 39ffa08..bfc7030 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) 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 -- cgit v1.1