aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2017-10-26 11:34:23 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2017-10-26 11:34:23 +0300
commita9a5d76f3fdac0ddbf76f7d021be3c95b7bfbdef (patch)
tree382f76cf3eea6b4126408878262fcc9bf502f1c2
parentd82eb4514d1951473ee93ad0276d1108a3519343 (diff)
downloadvmod-basicauth-a9a5d76f3fdac0ddbf76f7d021be3c95b7bfbdef.tar.gz
vmod-basicauth-a9a5d76f3fdac0ddbf76f7d021be3c95b7bfbdef.tar.bz2
Fix compiler warnings in md5.c
-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)
181 181
182/* The four core functions - F1 is optimized somewhat */ 182/* The four core functions - F1 is optimized somewhat */
183 183
184#define F1(x, y, z) (x & y | ~x & z) 184#define F1(x, y, z) ((x & y) | (~x & z))
185#define F2(x, y, z) F1(z, x, y) 185#define F2(x, y, z) F1(z, x, y)
186#define F3(x, y, z) (x ^ y ^ z) 186#define F3(x, y, z) (x ^ y ^ z)
187#define F4(x, y, z) (y ^ (x | ~z)) 187#define F4(x, y, z) (y ^ (x | ~z))
@@ -301,7 +301,8 @@ MD5Transform(uint32_t buf[4], uint32_t const cin[16])
301 * Define the Magic String prefix that identifies a password as being 301 * Define the Magic String prefix that identifies a password as being
302 * hashed using our algorithm. 302 * hashed using our algorithm.
303 */ 303 */
304static const char *const apr1_id = "$apr1$"; 304#define APR1_ID_STR "$apr1$"
305#define APR1_ID_LEN (sizeof(APR1_ID_STR)-1)
305 306
306/* 307/*
307 * The following MD5 password encryption code was largely borrowed from 308 * 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)
349 /* 350 /*
350 * If it starts with the magic string, then skip that. 351 * If it starts with the magic string, then skip that.
351 */ 352 */
352 if (!strncmp(sp, apr1_id, strlen(apr1_id))) { 353 if (!strncmp(sp, APR1_ID_STR, APR1_ID_LEN)) {
353 sp += strlen(apr1_id); 354 sp += APR1_ID_LEN;
354 } 355 }
355 356
356 /* 357 /*
@@ -372,25 +373,25 @@ apr_md5_encode(const char *pw, const char *salt, char *result, size_t nbytes)
372 /* 373 /*
373 * The password first, since that is what is most unknown 374 * The password first, since that is what is most unknown
374 */ 375 */
375 MD5Update(&ctx, pw, strlen(pw)); 376 MD5Update(&ctx, (unsigned char const*) pw, strlen(pw));
376 377
377 /* 378 /*
378 * Then our magic string 379 * Then our magic string
379 */ 380 */
380 MD5Update(&ctx, apr1_id, strlen(apr1_id)); 381 MD5Update(&ctx, (unsigned char const*)APR1_ID_STR, APR1_ID_LEN);
381 382
382 /* 383 /*
383 * Then the raw salt 384 * Then the raw salt
384 */ 385 */
385 MD5Update(&ctx, sp, sl); 386 MD5Update(&ctx, (unsigned char const*)sp, sl);
386 387
387 /* 388 /*
388 * Then just as many characters of the MD5(pw, salt, pw) 389 * Then just as many characters of the MD5(pw, salt, pw)
389 */ 390 */
390 MD5Init(&ctx1); 391 MD5Init(&ctx1);
391 MD5Update(&ctx1, pw, strlen(pw)); 392 MD5Update(&ctx1, (unsigned char const*)pw, strlen(pw));
392 MD5Update(&ctx1, sp, sl); 393 MD5Update(&ctx1, (unsigned char const*)sp, sl);
393 MD5Update(&ctx1, pw, strlen(pw)); 394 MD5Update(&ctx1, (unsigned char const*)pw, strlen(pw));
394 MD5Final(final, &ctx1); 395 MD5Final(final, &ctx1);
395 for (pl = strlen(pw); pl > 0; pl -= APR_MD5_DIGESTSIZE) { 396 for (pl = strlen(pw); pl > 0; pl -= APR_MD5_DIGESTSIZE) {
396 MD5Update(&ctx, final, 397 MD5Update(&ctx, final,
@@ -409,14 +410,14 @@ apr_md5_encode(const char *pw, const char *salt, char *result, size_t nbytes)
409 if (i & 1) 410 if (i & 1)
410 MD5Update(&ctx, final, 1); 411 MD5Update(&ctx, final, 1);
411 else 412 else
412 MD5Update(&ctx, pw, 1); 413 MD5Update(&ctx, (unsigned char const*)pw, 1);
413 } 414 }
414 415
415 /* 416 /*
416 * Now make the output string. We know our limitations, so we 417 * Now make the output string. We know our limitations, so we
417 * can use the string routines without bounds checking. 418 * can use the string routines without bounds checking.
418 */ 419 */
419 strcpy(passwd, apr1_id); 420 strcpy(passwd, APR1_ID_STR);
420 strncat(passwd, sp, sl); 421 strncat(passwd, sp, sl);
421 strcat(passwd, "$"); 422 strcat(passwd, "$");
422 423
@@ -434,19 +435,19 @@ apr_md5_encode(const char *pw, const char *salt, char *result, size_t nbytes)
434 * so need to to set it each time through 435 * so need to to set it each time through
435 */ 436 */
436 if (i & 1) 437 if (i & 1)
437 MD5Update(&ctx1, pw, strlen(pw)); 438 MD5Update(&ctx1, (unsigned char const*)pw, strlen(pw));
438 else 439 else
439 MD5Update(&ctx1, final, APR_MD5_DIGESTSIZE); 440 MD5Update(&ctx1, final, APR_MD5_DIGESTSIZE);
440 if (i % 3) 441 if (i % 3)
441 MD5Update(&ctx1, sp, sl); 442 MD5Update(&ctx1, (unsigned char const*)sp, sl);
442 443
443 if (i % 7) 444 if (i % 7)
444 MD5Update(&ctx1, pw, strlen(pw)); 445 MD5Update(&ctx1, (unsigned char const*)pw, strlen(pw));
445 446
446 if (i & 1) 447 if (i & 1)
447 MD5Update(&ctx1, final, APR_MD5_DIGESTSIZE); 448 MD5Update(&ctx1, final, APR_MD5_DIGESTSIZE);
448 else 449 else
449 MD5Update(&ctx1, pw, strlen(pw)); 450 MD5Update(&ctx1, (unsigned char const*)pw, strlen(pw));
450 MD5Final(final,&ctx1); 451 MD5Final(final,&ctx1);
451 } 452 }
452 453

Return to:

Send suggestions and report system problems to the System administrator.