From 90c9d543a8b99360a6e2513eab868ea36a862cb0 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Sat, 20 Jan 2001 01:15:28 +0000 Subject: [PATCH] Provide extra salt for crypt(3) --- libraries/liblutil/passwd.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libraries/liblutil/passwd.c b/libraries/liblutil/passwd.c index 3fcfc3c271..e7262115c7 100644 --- a/libraries/liblutil/passwd.c +++ b/libraries/liblutil/passwd.c @@ -1176,7 +1176,7 @@ static struct berval *hash_crypt( const struct berval *passwd ) { struct berval hash; - unsigned char salt[3]; + unsigned char salt[9]; /* salt suitable for anything */ int i; for( i=0; ibv_len; i++) { @@ -1189,13 +1189,14 @@ static struct berval *hash_crypt( return NULL; /* passwd must behave like a string */ } - if( lutil_entropy( salt, sizeof(salt)) < 0 ) { + if( lutil_entropy( salt, 8) < 0 ) { return NULL; } - salt[0] = crypt64[ salt[0] % (sizeof(crypt64)-1) ]; - salt[1] = crypt64[ salt[1] % (sizeof(crypt64)-1) ]; - salt[2] = '\0'; + for( i=0; i<8; i++ ) { + salt[i] = crypt64[ salt[i] % (sizeof(crypt64)-1) ]; + } + salt[8] = '\0'; hash.bv_val = crypt( passwd->bv_val, salt ); -- 2.39.5