]> granicus.if.org Git - php/commitdiff
Fix crypt salt not being converted to b64
authorLeigh <leigh@php.net>
Thu, 7 Jul 2016 14:32:38 +0000 (15:32 +0100)
committerLeigh <leigh@php.net>
Thu, 7 Jul 2016 14:32:38 +0000 (15:32 +0100)
ext/standard/crypt.c

index 3604e19b027d1f7436c75bf553c29a2a05a9a4ff..9e097ca6cf69269c36081ea9adc431abc73cce5c 100644 (file)
@@ -96,11 +96,10 @@ PHP_MSHUTDOWN_FUNCTION(crypt) /* {{{ */
 
 static unsigned char itoa64[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 
-static void php_to64(char *s, zend_long v, int n) /* {{{ */
+static void php_to64(char *s, int n) /* {{{ */
 {
        while (--n >= 0) {
-               *s++ = itoa64[v&0x3f];
-               v >>= 6;
+               *s++ = itoa64[*s&0x3f];
        }
 }
 /* }}} */
@@ -265,6 +264,7 @@ PHP_FUNCTION(crypt)
        if (!*salt) {
                strncpy(salt, "$1$", 3);
                php_random_bytes_throw(&salt[3], 8);
+               php_to64(&salt[3], 8);
                strncpy(&salt[11], "$", PHP_MAX_SALT_LEN - 11);
                salt_in_len = strlen(salt);
        } else {