summaryrefslogtreecommitdiffhomepage
path: root/libbb/pw_encrypt.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/pw_encrypt.c')
-rw-r--r--libbb/pw_encrypt.c9
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)
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