From: Ralf S. Engelschall Date: Mon, 27 Sep 1999 07:19:55 +0000 (+0000) Subject: Make the support stuff finitely working again. X-Git-Tag: 1.3.10~315 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5605139ae2fd483ada31e4339129a124155528c;p=thirdparty%2Fapache%2Fhttpd.git Make the support stuff finitely working again. BTW, how can it be that nowadays it can happen that the Apache Group has a source tree which doesn't compile under Unix for more than two weeks (I was busy with exams and it didn't compile src/support/ already there)? In the past this was definitely not possible. Seems like the source-centered hacker focus drifts away... sorry, for me this seems like a horrifying evolution, friends. Please let us always make sure that the source at least compiles. I don't want to say it should also run, but hell, it should at least compile and if not it should be fixed within a few days... git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@83919 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/support/htpasswd.c b/support/htpasswd.c index 21a24e0c0a3..e65daba095d 100644 --- a/support/htpasswd.c +++ b/support/htpasswd.c @@ -152,6 +152,17 @@ static void putline(FILE *f, char *l) fputc('\n', f); } +static void to64(char *s, unsigned long v, int n) +{ + static unsigned char itoa64[] = /* 0 ... 63 => ASCII - 64 */ + "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + + while (--n >= 0) { + *s++ = itoa64[v&0x3f]; + v >>= 6; + } +} + /* * Make a password record from the given information. A zero return * indicates success; failure means that the output buffer contains an @@ -192,7 +203,7 @@ static int mkrecord(char *user, char *record, size_t rlen, char *passwd, case ALG_APMD5: (void) srand((int) time((time_t *) NULL)); - ap_to64(&salt[0], rand(), 8); + to64(&salt[0], rand(), 8); salt[8] = '\0'; ap_MD5Encode((const unsigned char *)pw, (const unsigned char *)salt, @@ -207,7 +218,7 @@ static int mkrecord(char *user, char *record, size_t rlen, char *passwd, case ALG_CRYPT: default: (void) srand((int) time((time_t *) NULL)); - ap_to64(&salt[0], rand(), 8); + to64(&salt[0], rand(), 8); salt[8] = '\0'; ap_cpystrn(cpw, (char *)crypt(pw, salt), sizeof(cpw) - 1);