Skip to content

Commit

Permalink
Handle *0 / *1 more consistently
Browse files Browse the repository at this point in the history
Avoid throwing a DES salt deprecation warning if the libc crypt
implementation is used.
  • Loading branch information
nikic committed Jun 24, 2020
1 parent 32257ac commit 565baf0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ext/standard/crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */

Expand Down

0 comments on commit 565baf0

Please sign in to comment.