]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixes various warnings emitted in lib by the SunPRO cc compiler, and
authorhno <>
Wed, 17 Oct 2001 19:30:49 +0000 (19:30 +0000)
committerhno <>
Wed, 17 Oct 2001 19:30:49 +0000 (19:30 +0000)
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 *

include/md5.h
include/ntlmauth.h
lib/md5.c
lib/rfc2617.c

index 3e29aa250c16bead8c873545fd6b2ee1d5e1a78a..b06a9faece56f087eef01ab1303269997f989e43 100644 (file)
@@ -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
 
index 2d206047afca218889e058b236626198c2b46a5d..16659dd10c9412dd606710e1dd2cd0b79b8217ec 100644 (file)
@@ -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 * * * * * * *
  *
 #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.
index 2ae975669884bf73c88d41ade9b8fa9ebfae6f98..8952e29154aa31d03af9b2c9df44b2e80c54859b 100644 (file)
--- 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;
index 7648673bb2bf4d4fe64e69923153414833a261bf..15081b2cbc417d0bb972e1224b5584c02e154202 100644 (file)
@@ -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);
-};
+}