Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/libbb/pw_encrypt.c

    r3232 r3621  
    1010#include "libbb.h"
    1111
    12 /* static const uint8_t ascii64[] =
     12/* static const uint8_t ascii64[] ALIGN1 =
    1313 * "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    1414 */
     
    5353    int len = 2/2;
    5454    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 */
    5660        len = 8/2; /* so far assuming md5 */
    5761        *salt_ptr++ = '$';
     
    5963        *salt_ptr++ = '$';
    6064#if !ENABLE_USE_BB_CRYPT || ENABLE_USE_BB_CRYPT_SHA
    61         if (algo[0] == 's') { /* sha */
    62             salt[1] = '5' + (strcmp(algo, "sha512") == 0);
     65        if ((algo[0]|0x20) == 's') { /* sha */
     66            salt[1] = '5' + (strcasecmp(algo, "sha512") == 0);
    6367            len = 16/2;
    6468        }
     
    143147char* FAST_FUNC pw_encrypt(const char *clear, const char *salt, int cleanup)
    144148{
    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 : "");
    146157}
    147158
Note: See TracChangeset for help on using the changeset viewer.