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) (show 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
@@ -181,7 +181,7 @@ MD5Final(unsigned char digest[16], struct MD5Context *ctx)
/* 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))
@@ -301,7 +301,8 @@ MD5Transform(uint32_t buf[4], uint32_t const cin[16])
* 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
@@ -349,8 +350,8 @@ apr_md5_encode(const char *pw, const char *salt, char *result, size_t nbytes)
/*
* 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;
}
/*
@@ -372,25 +373,25 @@ apr_md5_encode(const char *pw, const char *salt, char *result, size_t nbytes)
/*
* 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,
@@ -409,14 +410,14 @@ apr_md5_encode(const char *pw, const char *salt, char *result, size_t nbytes)
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, "$");
@@ -434,19 +435,19 @@ apr_md5_encode(const char *pw, const char *salt, char *result, size_t nbytes)
* 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);
}

Return to:

Send suggestions and report system problems to the System administrator.