Skip to content

Commit 9d36be8

Browse files
committed
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".
1 parent 9c7df55 commit 9d36be8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ext/standard/crypt.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,17 @@ PHP_FUNCTION(crypt)
215215
RETURN_STRING("*0");
216216
}
217217
}
218+
else if (zend_string_equals_literal(result, "*")) {
219+
/* Musl crypt() uses "*" as a failure token rather
220+
* than the "*0" that libxcrypt/PHP use. Our test
221+
* suite in particular looks for "*0" in a few places,
222+
* and it would be annoying to handle both values
223+
* explicitly. It seems wise to abstract this detail
224+
* from the end user: if it's annoying for us, imagine
225+
* how annoying it would be in end-user code; not that
226+
* anyone would think of it. */
227+
RETURN_STRING("*0");
228+
}
218229
RETURN_STR(result);
219230
}
220231
/* }}} */

0 commit comments

Comments
 (0)