Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/libbb/pw_encrypt.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/libbb/pw_encrypt.c
r3232 r3621 10 10 #include "libbb.h" 11 11 12 /* static const uint8_t ascii64[] =12 /* static const uint8_t ascii64[] ALIGN1 = 13 13 * "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 14 14 */ … … 53 53 int len = 2/2; 54 54 char *salt_ptr = salt; 55 if (algo[0] != 'd') { /* not des */ 55 56 /* Standard chpasswd uses uppercase algos ("MD5", not "md5"). 57 * Need to be case-insensitive in the code below. 58 */ 59 if ((algo[0]|0x20) != 'd') { /* not des */ 56 60 len = 8/2; /* so far assuming md5 */ 57 61 *salt_ptr++ = '$'; … … 59 63 *salt_ptr++ = '$'; 60 64 #if !ENABLE_USE_BB_CRYPT || ENABLE_USE_BB_CRYPT_SHA 61 if ( algo[0]== 's') { /* sha */62 salt[1] = '5' + (strc mp(algo, "sha512") == 0);65 if ((algo[0]|0x20) == 's') { /* sha */ 66 salt[1] = '5' + (strcasecmp(algo, "sha512") == 0); 63 67 len = 16/2; 64 68 } … … 143 147 char* FAST_FUNC pw_encrypt(const char *clear, const char *salt, int cleanup) 144 148 { 145 return xstrdup(crypt(clear, salt)); 149 char *s; 150 151 s = crypt(clear, salt); 152 /* 153 * glibc used to return "" on malformed salts (for example, ""), 154 * but since 2.17 it returns NULL. 155 */ 156 return xstrdup(s ? s : ""); 146 157 } 147 158
Note:
See TracChangeset
for help on using the changeset viewer.