Skip to content

Commit e9ee9e1

Browse files
committed
Merge branch 'PHP-7.0'
2 parents 6c47455 + bd90f55 commit e9ee9e1

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

ext/standard/crypt.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,13 @@ PHPAPI zend_string *php_crypt(const char *password, const int pass_len, const ch
246246
}
247247
#else
248248

249+
if (salt[0] != '$' && salt[0] != '_' && (!IS_VALID_SALT_CHARACTER(salt[0]) || !IS_VALID_SALT_CHARACTER(salt[1]))) {
250+
if (!quiet) {
251+
/* error consistently about invalid DES fallbacks */
252+
php_error_docref(NULL, E_DEPRECATED, DES_INVALID_SALT_ERROR);
253+
}
254+
}
255+
249256
# if defined(HAVE_CRYPT_R) && (defined(_REENTRANT) || defined(_THREAD_SAFE))
250257
{
251258
# if defined(CRYPT_R_STRUCT_CRYPT_DATA)
@@ -254,24 +261,23 @@ PHPAPI zend_string *php_crypt(const char *password, const int pass_len, const ch
254261
# elif defined(CRYPT_R_CRYPTD)
255262
CRYPTD buffer;
256263
# else
257-
# error Data struct used by crypt_r() is unknown. Please report.
264+
# error Data struct used by crypt_r() is unknown. Please report.
258265
# endif
259-
if (salt[0] != '$' && salt[0] != '_' && (!IS_VALID_SALT_CHARACTER(salt[0]) || !IS_VALID_SALT_CHARACTER(salt[1]))) {
260-
if (!quiet) {
261-
/* error consistently about invalid DES fallbacks */
262-
php_error_docref(NULL, E_DEPRECATED, DES_INVALID_SALT_ERROR);
263-
}
264-
}
265266
crypt_res = crypt_r(password, salt, &buffer);
266-
if (!crypt_res || (salt[0] == '*' && salt[1] == '0')) {
267-
return NULL;
268-
} else {
269-
result = zend_string_init(crypt_res, strlen(crypt_res), 0);
270-
return result;
271-
}
272267
}
268+
# elif defined(HAVE_CRYPT)
269+
crypt_res = crypt(password, salt);
270+
# else
271+
# error No crypt() implementation
273272
# endif
274273
#endif
274+
275+
if (!crypt_res || (salt[0] == '*' && salt[1] == '0')) {
276+
return NULL;
277+
} else {
278+
result = zend_string_init(crypt_res, strlen(crypt_res), 0);
279+
return result;
280+
}
275281
}
276282
/* }}} */
277283

0 commit comments

Comments
 (0)