summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2017-10-26 08:34:23 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2017-10-26 08:34:23 (GMT)
commita9a5d76f3fdac0ddbf76f7d021be3c95b7bfbdef (patch) (side-by-side diff)
tree382f76cf3eea6b4126408878262fcc9bf502f1c2
parentd82eb4514d1951473ee93ad0276d1108a3519343 (diff)
downloadvmod-basicauth-a9a5d76f3fdac0ddbf76f7d021be3c95b7bfbdef.tar.gz
vmod-basicauth-a9a5d76f3fdac0ddbf76f7d021be3c95b7bfbdef.tar.bz2
Fix compiler warnings in md5.c
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/md5.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/md5.c b/src/md5.c
index 8c0d9a6..1bb02d7 100644
--- a/src/md5.c
+++ b/src/md5.c
@@ -178,13 +178,13 @@ MD5Final(unsigned char digest[16], struct MD5Context *ctx)
bytes_encode(digest,ctx->buf,16);
memset((char *) ctx, 0, sizeof(ctx)); /* In case it's sensitive */
}
/* The four core functions - F1 is optimized somewhat */
-#define F1(x, y, z) (x & y | ~x & z)
+#define F1(x, y, z) ((x & y) | (~x & z))
#define F2(x, y, z) F1(z, x, y)
#define F3(x, y, z) (x ^ y ^ z)
#define F4(x, y, z) (y ^ (x | ~z))
/* This is the central step in the MD5 algorithm. */
#define MD5STEP(f, w, x, y, z, data, s) \
@@ -298,13 +298,14 @@ MD5Transform(uint32_t buf[4], uint32_t const cin[16])
/* APR-specific code */
/*
* Define the Magic String prefix that identifies a password as being
* hashed using our algorithm.
*/
-static const char *const apr1_id = "$apr1$";
+#define APR1_ID_STR "$apr1$"
+#define APR1_ID_LEN (sizeof(APR1_ID_STR)-1)
/*
* The following MD5 password encryption code was largely borrowed from
* the FreeBSD 3.0 /usr/src/lib/libcrypt/crypt.c file, which is
* licenced as stated at the top of this file.
*/
@@ -346,14 +347,14 @@ apr_md5_encode(const char *pw, const char *salt, char *result, size_t nbytes)
*/
sp = salt;
/*
* If it starts with the magic string, then skip that.
*/
- if (!strncmp(sp, apr1_id, strlen(apr1_id))) {
- sp += strlen(apr1_id);
+ if (!strncmp(sp, APR1_ID_STR, APR1_ID_LEN)) {
+ sp += APR1_ID_LEN;
}
/*
* It stops at the first '$' or 8 chars, whichever comes first
*/
for (ep = sp; (*ep != '\0') && (*ep != '$') && (ep < (sp + 8)); ep++)
@@ -369,31 +370,31 @@ apr_md5_encode(const char *pw, const char *salt, char *result, size_t nbytes)
*/
MD5Init(&ctx);
/*
* The password first, since that is what is most unknown
*/
- MD5Update(&ctx, pw, strlen(pw));
+ MD5Update(&ctx, (unsigned char const*) pw, strlen(pw));
/*
* Then our magic string
*/
- MD5Update(&ctx, apr1_id, strlen(apr1_id));
+ MD5Update(&ctx, (unsigned char const*)APR1_ID_STR, APR1_ID_LEN);
/*
* Then the raw salt
*/
- MD5Update(&ctx, sp, sl);
+ MD5Update(&ctx, (unsigned char const*)sp, sl);
/*
* Then just as many characters of the MD5(pw, salt, pw)
*/
MD5Init(&ctx1);
- MD5Update(&ctx1, pw, strlen(pw));
- MD5Update(&ctx1, sp, sl);
- MD5Update(&ctx1, pw, strlen(pw));
+ MD5Update(&ctx1, (unsigned char const*)pw, strlen(pw));
+ MD5Update(&ctx1, (unsigned char const*)sp, sl);
+ MD5Update(&ctx1, (unsigned char const*)pw, strlen(pw));
MD5Final(final, &ctx1);
for (pl = strlen(pw); pl > 0; pl -= APR_MD5_DIGESTSIZE) {
MD5Update(&ctx, final,
(pl > APR_MD5_DIGESTSIZE) ? APR_MD5_DIGESTSIZE : pl);
}
@@ -406,20 +407,20 @@ apr_md5_encode(const char *pw, const char *salt, char *result, size_t nbytes)
* Then something really weird...
*/
for (i = strlen(pw); i != 0; i >>= 1) {
if (i & 1)
MD5Update(&ctx, final, 1);
else
- MD5Update(&ctx, pw, 1);
+ MD5Update(&ctx, (unsigned char const*)pw, 1);
}
/*
* Now make the output string. We know our limitations, so we
* can use the string routines without bounds checking.
*/
- strcpy(passwd, apr1_id);
+ strcpy(passwd, APR1_ID_STR);
strncat(passwd, sp, sl);
strcat(passwd, "$");
MD5Final(final, &ctx);
/*
@@ -431,25 +432,25 @@ apr_md5_encode(const char *pw, const char *salt, char *result, size_t nbytes)
MD5Init(&ctx1);
/*
* apr_md5_final clears out ctx1.xlate at the end of each loop,
* so need to to set it each time through
*/
if (i & 1)
- MD5Update(&ctx1, pw, strlen(pw));
+ MD5Update(&ctx1, (unsigned char const*)pw, strlen(pw));
else
MD5Update(&ctx1, final, APR_MD5_DIGESTSIZE);
if (i % 3)
- MD5Update(&ctx1, sp, sl);
+ MD5Update(&ctx1, (unsigned char const*)sp, sl);
if (i % 7)
- MD5Update(&ctx1, pw, strlen(pw));
+ MD5Update(&ctx1, (unsigned char const*)pw, strlen(pw));
if (i & 1)
MD5Update(&ctx1, final, APR_MD5_DIGESTSIZE);
else
- MD5Update(&ctx1, pw, strlen(pw));
+ MD5Update(&ctx1, (unsigned char const*)pw, strlen(pw));
MD5Final(final,&ctx1);
}
p = passwd + strlen(passwd);
l = (final[ 0]<<16) | (final[ 6]<<8) | final[12]; to64(p, l, 4); p += 4;

Return to:

Send suggestions and report system problems to the System administrator.