From: hno <> Date: Wed, 17 Oct 2001 19:30:49 +0000 (+0000) Subject: Fixes various warnings emitted in lib by the SunPRO cc compiler, and X-Git-Tag: SQUID_3_0_PRE1~1357 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a76e35b13e9a0bc4ef02d4f1b336f4a96ec5b28c;p=thirdparty%2Fsquid.git Fixes various warnings emitted in lib by the SunPRO cc compiler, and synchronized the MD5 prototypes with OpenSSL. * MD5 operates on binary data, not characters. Avoid signed/unsigned issues * The bswap16/32 macros was not signed/unsigned safe * lib/rfc2617 had several spurious extra ; * MD5Final wants an unsigned char * --- diff --git a/include/md5.h b/include/md5.h index 3e29aa250c..b06a9faece 100644 --- a/include/md5.h +++ b/include/md5.h @@ -1,5 +1,5 @@ /* - * $Id: md5.h,v 1.10 2001/10/08 16:18:31 hno Exp $ + * $Id: md5.h,v 1.11 2001/10/17 13:30:49 hno Exp $ */ #ifndef SQUID_MD5_H @@ -57,8 +57,8 @@ typedef struct { } MD5_CTX; void MD5Init(MD5_CTX *); -void MD5Update(MD5_CTX *, const unsigned char *, unsigned int); -void MD5Final(unsigned char[16], MD5_CTX *); +void MD5Update(MD5_CTX *, const void *, unsigned long); +void MD5Final(unsigned char *, MD5_CTX *); #define MD5_DIGEST_CHARS 16 diff --git a/include/ntlmauth.h b/include/ntlmauth.h index 2d206047af..16659dd10c 100644 --- a/include/ntlmauth.h +++ b/include/ntlmauth.h @@ -1,5 +1,5 @@ /* - * $Id: ntlmauth.h,v 1.6 2001/10/08 16:18:31 hno Exp $ + * $Id: ntlmauth.h,v 1.7 2001/10/17 13:30:49 hno Exp $ * * * * * * * * * Legal stuff * * * * * * * * @@ -70,10 +70,10 @@ #define bswap16(x) bswap_16(x) #define bswap32(x) bswap_32(x) #else /* HAVE_BISTWAP_H */ -#define bswap16(x) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)) +#define bswap16(x) (((((uint16_t)x) >> 8) & 0xff) | ((((uint16_t)x) & 0xff) << 8)) #define bswap32(x) \ - ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ - (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) + (((((uint32_t)x) & 0xff000000) >> 24) | ((((uint32_t)x) & 0x00ff0000) >> 8) | \ + ((((uint32_t)x) & 0x0000ff00) << 8) | ((((uint32_t)x) & 0x000000ff) << 24)) #endif /* HAVE_BITSWAP_H */ /* Used internally. Microsoft seems to think this is right, I believe them. diff --git a/lib/md5.c b/lib/md5.c index 2ae9756698..8952e29154 100644 --- a/lib/md5.c +++ b/lib/md5.c @@ -1,5 +1,5 @@ /* - * $Id: md5.c,v 1.12 2001/04/14 00:03:20 hno Exp $ + * $Id: md5.c,v 1.13 2001/10/17 13:30:50 hno Exp $ */ /* taken from RFC-1321/Appendix A.3 */ @@ -146,9 +146,10 @@ MD5Init(MD5_CTX * context) * processing another message block, and updating the context. */ void -MD5Update(MD5_CTX * context, const unsigned char *input, unsigned int inputLen) +MD5Update(MD5_CTX * context, const void *input_p, unsigned long inputLen) { unsigned int i, index, partLen; + const unsigned char *input = input_p; /* Compute number of bytes mod 64 */ index = (unsigned int) ((context->count[0] >> 3) & 0x3F); @@ -184,7 +185,7 @@ MD5Update(MD5_CTX * context, const unsigned char *input, unsigned int inputLen) * message digest and zeroizing the context. */ void -MD5Final(unsigned char digest[16], MD5_CTX * context) +MD5Final(unsigned char *digest, MD5_CTX * context) { unsigned char bits[8]; unsigned int index, padLen; diff --git a/lib/rfc2617.c b/lib/rfc2617.c index 7648673bb2..15081b2cbc 100644 --- a/lib/rfc2617.c +++ b/lib/rfc2617.c @@ -13,7 +13,7 @@ /* - * $Id: rfc2617.c,v 1.4 2001/10/17 12:41:48 hno Exp $ + * $Id: rfc2617.c,v 1.5 2001/10/17 13:30:50 hno Exp $ * * DEBUG: * AUTHOR: RFC 2617 & Robert Collins @@ -68,9 +68,9 @@ CvtHex(const HASH Bin, HASHHEX Hex) Hex[i * 2 + 1] = (j + '0'); else Hex[i * 2 + 1] = (j + 'a' - 10); - }; + } Hex[HASHHEXLEN] = '\0'; -}; +} void CvtBin(const HASHHEX Hex, HASH Bin) @@ -84,9 +84,9 @@ CvtBin(const HASHHEX Hex, HASH Bin) Bin[i / 2] |= ((j - '0') << ((i % 2 == 0) ? 4 : 0)); else Bin[i / 2] |= ((j - 'a' + 10) << ((i % 2 == 0) ? 4 : 0)); - }; + } Bin[HASHLEN] = '\0'; -}; +} /* calculate H(A1) as per spec */ @@ -111,7 +111,7 @@ DigestCalcHA1( MD5Update(&Md5Ctx, pszRealm, strlen(pszRealm)); MD5Update(&Md5Ctx, ":", 1); MD5Update(&Md5Ctx, pszPassword, strlen(pszPassword)); - MD5Final(HA1, &Md5Ctx); + MD5Final((unsigned char *)HA1, &Md5Ctx); } if (strcasecmp(pszAlg, "md5-sess") == 0) { MD5Init(&Md5Ctx); @@ -120,10 +120,10 @@ DigestCalcHA1( MD5Update(&Md5Ctx, pszNonce, strlen(pszNonce)); MD5Update(&Md5Ctx, ":", 1); MD5Update(&Md5Ctx, pszCNonce, strlen(pszCNonce)); - MD5Final(HA1, &Md5Ctx); - }; + MD5Final((unsigned char *)HA1, &Md5Ctx); + } CvtHex(HA1, SessionKey); -}; +} /* calculate request-digest/response-digest as per HTTP Digest spec */ void @@ -153,8 +153,8 @@ DigestCalcResponse( if (strcasecmp(pszQop, "auth-int") == 0) { MD5Update(&Md5Ctx, ":", 1); MD5Update(&Md5Ctx, HEntity, HASHHEXLEN); - }; - MD5Final(HA2, &Md5Ctx); + } + MD5Final((unsigned char *)HA2, &Md5Ctx); CvtHex(HA2, HA2Hex); /* calculate response @@ -171,8 +171,8 @@ DigestCalcResponse( MD5Update(&Md5Ctx, ":", 1); MD5Update(&Md5Ctx, pszQop, strlen(pszQop)); MD5Update(&Md5Ctx, ":", 1); - }; + } MD5Update(&Md5Ctx, HA2Hex, HASHHEXLEN); - MD5Final(RespHash, &Md5Ctx); + MD5Final((unsigned char *)RespHash, &Md5Ctx); CvtHex(RespHash, Response); -}; +}