summaryrefslogtreecommitdiff
path: root/test/badsalt.c
diff options
context:
space:
mode:
authorBjörn Esser <besser82@fedoraproject.org>2020-06-28 10:10:23 +0200
committerBjörn Esser <besser82@fedoraproject.org>2020-08-18 17:23:34 +0200
commitb2b813adbd9d7cc7d20a9b984ef27b64df8c15d9 (patch)
tree8bd151bb2b6d63fbf5e4158d5fb2489afccfaab8 /test/badsalt.c
parent328563be4eca503565de5fcb23dac656e2317ad6 (diff)
downloadlibxcrypt-b2b813adbd9d7cc7d20a9b984ef27b64df8c15d9.tar.gz
libxcrypt-b2b813adbd9d7cc7d20a9b984ef27b64df8c15d9.tar.bz2
libxcrypt-b2b813adbd9d7cc7d20a9b984ef27b64df8c15d9.zip
Salt string compatibility with generic implementations.
All other existing implementations of the md5crypt, sha256crypt, and sha512crypt hashing methods allow any ASCII character to be present in the salt string. We changed our implementation of these hash methods to be compliant with the general behaviour, except for the colon ':' character, which serves a special purpose in the Unix shadow file. Also adapt test/badsalt.c to expect the colon characters is an invalid salt character for all hashing methods. Fixes #105
Diffstat (limited to 'test/badsalt.c')
-rw-r--r--test/badsalt.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/test/badsalt.c b/test/badsalt.c
index 887ce4a..803b575 100644
--- a/test/badsalt.c
+++ b/test/badsalt.c
@@ -252,7 +252,7 @@ check_results (const char *label, const char *fn,
{
if (retval[0] == '*' ||
strncmp (retval, setting,
- (setting[l_setting - 1] == '*') ? l_setting - 1 : l_setting))
+ (setting[l_setting - 1] == ':') ? l_setting - 1 : l_setting))
{
printf ("FAIL: %s/%s/%s: expected success, got non-matching %s\n",
label, setting, fn, retval);
@@ -432,7 +432,10 @@ test_one_case (const struct testcase *t,
result of the hash computation. */
p = page + pagesize - (t->plen + 2);
memcpy (p, goodhash, t->plen);
- p[t->plen] = '*';
+
+ /* The asterisk is a valid salt character for some hashes,
+ but the colon is never a valid salt character. */
+ p[t->plen] = ':';
p[t->plen+1] = '\0';
if (!test_one_setting (t->label, p, cd, true))
return false;