@@ -246,6 +246,13 @@ PHPAPI zend_string *php_crypt(const char *password, const int pass_len, const ch
246
246
}
247
247
#else
248
248
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
+
249
256
# if defined(HAVE_CRYPT_R ) && (defined(_REENTRANT ) || defined(_THREAD_SAFE ))
250
257
{
251
258
# 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
254
261
# elif defined(CRYPT_R_CRYPTD )
255
262
CRYPTD buffer ;
256
263
# 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.
258
265
# 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
- }
265
266
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
- }
272
267
}
268
+ # elif defined(HAVE_CRYPT )
269
+ crypt_res = crypt (password , salt );
270
+ # else
271
+ # error No crypt() implementation
273
272
# endif
274
273
#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
+ }
275
281
}
276
282
/* }}} */
277
283
0 commit comments