]> granicus.if.org Git - php/commitdiff
Handle *0 / *1 more consistently
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 24 Jun 2020 10:20:05 +0000 (12:20 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 24 Jun 2020 10:22:07 +0000 (12:22 +0200)
Avoid throwing a DES salt deprecation warning if the libc crypt
implementation is used.

ext/standard/crypt.c

index b727575fad6db23e0e6ae3ebfe5cc6fed50cc64e..92430b69f7726362b0636b7368367d6cb32a5e69 100644 (file)
@@ -99,6 +99,11 @@ PHPAPI zend_string *php_crypt(const char *password, const int pass_len, const ch
 {
        char *crypt_res;
        zend_string *result;
+
+       if (salt[0] == '*' && (salt[1] == '0' || salt[1] == '1')) {
+               return NULL;
+       }
+
 /* Windows (win32/crypt) has a stripped down version of libxcrypt and
        a CryptoApi md5_crypt implementation */
 #if PHP_USE_PHP_CRYPT_R
@@ -160,8 +165,6 @@ PHPAPI zend_string *php_crypt(const char *password, const int pass_len, const ch
                                ZEND_SECURE_ZERO(output, PHP_MAX_SALT_LEN + 1);
                                return result;
                        }
-        } else if (salt[0] == '*' && (salt[1] == '0' || salt[1] == '1')) {
-            return NULL;
                } else {
                        /* DES Fallback */