aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-06-12 16:56:52 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-06-12 16:56:52 +0000
commitfdddab0c61c55c25d4218d4370e2b16a7936a794 (patch)
treebf93480018a52ab051189222248b6d04af98d7d4 /libbb
parent4ea83bf562c44a6792e7c77e7d87cba91f86f763 (diff)
downloadbusybox-w32-fdddab0c61c55c25d4218d4370e2b16a7936a794.tar.gz
busybox-w32-fdddab0c61c55c25d4218d4370e2b16a7936a794.tar.bz2
busybox-w32-fdddab0c61c55c25d4218d4370e2b16a7936a794.zip
make pw_encrypt() return malloc'ed string.
text data bss dec hex filename 759802 604 6684 767090 bb472 busybox_old 759804 604 6676 767084 bb46c busybox_unstripped
Diffstat (limited to 'libbb')
-rw-r--r--libbb/correct_password.c5
-rw-r--r--libbb/pw_encrypt.c7
2 files changed, 7 insertions, 5 deletions
diff --git a/libbb/correct_password.c b/libbb/correct_password.c
index a4ded8b5f..f0b9384ea 100644
--- a/libbb/correct_password.c
+++ b/libbb/correct_password.c
@@ -40,6 +40,7 @@ int correct_password(const struct passwd *pw)
40{ 40{
41 char *unencrypted, *encrypted; 41 char *unencrypted, *encrypted;
42 const char *correct; 42 const char *correct;
43 int r;
43#if ENABLE_FEATURE_SHADOWPASSWDS 44#if ENABLE_FEATURE_SHADOWPASSWDS
44 /* Using _r function to avoid pulling in static buffers */ 45 /* Using _r function to avoid pulling in static buffers */
45 struct spwd spw; 46 struct spwd spw;
@@ -72,6 +73,8 @@ int correct_password(const struct passwd *pw)
72 return 0; 73 return 0;
73 } 74 }
74 encrypted = pw_encrypt(unencrypted, correct, 1); 75 encrypted = pw_encrypt(unencrypted, correct, 1);
76 r = (strcmp(encrypted, correct) == 0);
77 free(encrypted);
75 memset(unencrypted, 0, strlen(unencrypted)); 78 memset(unencrypted, 0, strlen(unencrypted));
76 return strcmp(encrypted, correct) == 0; 79 return r;
77} 80}
diff --git a/libbb/pw_encrypt.c b/libbb/pw_encrypt.c
index d439fc3b4..762cbab27 100644
--- a/libbb/pw_encrypt.c
+++ b/libbb/pw_encrypt.c
@@ -54,7 +54,7 @@ static void my_crypt_cleanup(void)
54 54
55char *pw_encrypt(const char *clear, const char *salt, int cleanup) 55char *pw_encrypt(const char *clear, const char *salt, int cleanup)
56{ 56{
57 static char *cipher; 57 char *encrypted;
58 58
59#if 0 /* was CONFIG_FEATURE_SHA1_PASSWORDS, but there is no such thing??? */ 59#if 0 /* was CONFIG_FEATURE_SHA1_PASSWORDS, but there is no such thing??? */
60 if (strncmp(salt, "$2$", 3) == 0) { 60 if (strncmp(salt, "$2$", 3) == 0) {
@@ -62,11 +62,10 @@ char *pw_encrypt(const char *clear, const char *salt, int cleanup)
62 } 62 }
63#endif 63#endif
64 64
65 free(cipher); 65 encrypted = my_crypt(clear, salt);
66 cipher = my_crypt(clear, salt);
67 66
68 if (cleanup) 67 if (cleanup)
69 my_crypt_cleanup(); 68 my_crypt_cleanup();
70 69
71 return cipher; 70 return encrypted;
72} 71}