1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

ext/standard/crypt.c: handle musl failure tokens

Musl's crypt() returns "*" to indicate failure in contrast with the
"*0" returned by PHP/libxcrypt. This causes test failures, but more
importantly, is a pretty silly thing to expect the user to know.
This commit catches the musl value and turns it into "*0".
This commit is contained in:
Michael Orlitzky
2024-11-04 18:50:07 -05:00
committed by Arnaud Le Blanc
parent f5d2e7b779
commit 4dc0b40f42

View File

@@ -177,7 +177,19 @@ PHPAPI zend_string *php_crypt(const char *password, const int pass_len, const ch
if (!crypt_res || (salt[0] == '*' && salt[1] == '0')) {
return NULL;
} else {
}
else if (!strcmp(crypt_res, "*")) {
/* Musl crypt() uses "*" as a failure token rather
* than the "*0" that libxcrypt/PHP use. Our test
* suite in particular looks for "*0" in a few places,
* and it would be annoying to handle both values
* explicitly. It seems wise to abstract this detail
* from the end user: if it's annoying for us, imagine
* how annoying it would be in end-user code; not that
* anyone would think of it. */
return NULL;
}
else {
result = zend_string_init(crypt_res, strlen(crypt_res), 0);
return result;
}