make pw_encrypt() return malloc'ed string.
[oweals/busybox.git] / libbb / pw_encrypt.c
index d439fc3b4cab00d9c6b77e1a126eee9d494d360c..762cbab27ab001ea498b8d5792242beebe31ecac 100644 (file)
@@ -54,7 +54,7 @@ static void my_crypt_cleanup(void)
 
 char *pw_encrypt(const char *clear, const char *salt, int cleanup)
 {
-       static char *cipher;
+       char *encrypted;
 
 #if 0 /* was CONFIG_FEATURE_SHA1_PASSWORDS, but there is no such thing??? */
        if (strncmp(salt, "$2$", 3) == 0) {
@@ -62,11 +62,10 @@ char *pw_encrypt(const char *clear, const char *salt, int cleanup)
        }
 #endif
 
-       free(cipher);
-       cipher = my_crypt(clear, salt);
+       encrypted = my_crypt(clear, salt);
 
        if (cleanup)
                my_crypt_cleanup();
 
-       return cipher;
+       return encrypted;
 }