From 738f67db54d4d5460c287b191e89b39ed3ec589b Mon Sep 17 00:00:00 2001 From: deraadt Date: Thu, 27 Mar 1997 23:02:58 +0000 Subject: [PATCH] pretty and one 64bit thingy --- usr.bin/passwd/pwd_gensalt.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/usr.bin/passwd/pwd_gensalt.c b/usr.bin/passwd/pwd_gensalt.c index cf6ad0dc3e3..bd3f1985e16 100644 --- a/usr.bin/passwd/pwd_gensalt.c +++ b/usr.bin/passwd/pwd_gensalt.c @@ -37,7 +37,7 @@ #include #include -void to64( char *, long, int n); +void to64 __P((char *, int32_t, int n)); int pwd_gensalt(salt, max, pwd, type) @@ -64,19 +64,19 @@ pwd_gensalt(salt, max, pwd, type) next = option; now = strsep(&next, ","); if (!strcmp(now, "old")) { - if( max < 3 ) + if (max < 3) return 0; to64(&salt[0], arc4random(), 2); salt[2] = '\0'; } else if (!strcmp(now, "newsalt")) { - if( max < 10 ) + if (max < 10) return 0; salt[0] = _PASSWORD_EFMT1; - to64(&salt[1], (long) (29 * 25), 4); + to64(&salt[1], (int32_t) (29 * 25), 4); to64(&salt[5], arc4random(), 4); salt[9] = '\0'; } else if (!strcmp(now, "md5")) { - if( max < 13 ) /* $1$8salt$\0 */ + if (max < 13) /* $1$8salt$\0 */ return 0; strcpy(salt, "$1$"); to64(&salt[3], arc4random(), 4); @@ -95,16 +95,17 @@ pwd_gensalt(salt, max, pwd, type) return 1; } -static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */ - "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; +static unsigned char itoa64[] = /* 0 ... 63 => ascii - 64 */ + "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; -void to64(s, v, n) - register char *s; - register long v; - register int n; +void +to64(s, v, n) + register char *s; + register int32_t v; + register int n; { - while (--n >= 0) { - *s++ = itoa64[v&0x3f]; - v >>= 6; - } + while (--n >= 0) { + *s++ = itoa64[v&0x3f]; + v >>= 6; + } } -- 2.20.1