]> Pileus Git - ~andy/fetchmail/commitdiff
Fix MD5 compile on Solaris.
authorMatthias Andree <matthias.andree@gmx.de>
Thu, 18 Mar 2010 23:07:08 +0000 (00:07 +0100)
committerMatthias Andree <matthias.andree@gmx.de>
Thu, 18 Mar 2010 23:07:08 +0000 (00:07 +0100)
configure.ac
cram.c
fetchmail.h
md5c.c
smtp.c
transact.c

index 6f47a32c44560a200e0840512feaf59245328726..2076ca866e729c33dd45a8fb460b4723307d785d 100644 (file)
@@ -114,8 +114,8 @@ darwin*)
     ;;
 # Check for FreeBSD special case: more libs needed
 freebsd*)
-    AC_MSG_NOTICE(found FreeBSD - Adding -lmd -lkvm -lcom_err to standard libraries)
-    LIBS="$LIBS -lmd -lkvm -lcom_err"
+    AC_MSG_NOTICE(found FreeBSD - Adding -lkvm -lcom_err to standard libraries)
+    LIBS="$LIBS -lkvm -lcom_err"
     ;;
 # Check for LynxOS special case: -lbsd needed (at least on 2.3.0) and -s
 # not working.
@@ -170,7 +170,7 @@ dnl                 [LIBS="$LIBS -lintl"])
 
 AC_REPLACE_FUNCS([strstr strcasecmp memmove stpcpy strlcpy strlcat])
 
-AC_CHECK_FUNC(MD5Init, [],
+AC_SEARCH_LIBS(MD5Init, [md5, md], [],
              [AC_LIBSOURCE(md5c.c)
                EXTRAOBJ="$EXTRAOBJ md5c.\$(OBJEXT)"])
 
diff --git a/cram.c b/cram.c
index e71f0ecd3bc5496f967a8552538f11a6ff85cf25..cf33393ebb9662e6a69ae8eb4352d35ee6c3570e 100644 (file)
--- a/cram.c
+++ b/cram.c
@@ -18,7 +18,7 @@
 #include "fm_md5.h"
 
 void hmac_md5 (const unsigned char *password,  size_t pass_len,
-               const char *challenge, size_t chal_len,
+               const unsigned char *challenge, size_t chal_len,
                unsigned char *response,  size_t resp_len)
 {
     int i;
@@ -111,7 +111,7 @@ int do_cram_md5 (int sock, const char *command, struct query *ctl, const char *s
      */
 
     hmac_md5((unsigned char *)ctl->password, strlen(ctl->password),
-              msg_id, strlen (msg_id),
+              (unsigned char *)msg_id, strlen (msg_id),
               response, sizeof (response));
 
     snprintf (reply, sizeof(reply),
index a786caf2bb75eb1bc8d6a01f1b060695aaeda0d0..bc9abf03c4766493d6a3297bb075f6343d13be3e 100644 (file)
@@ -652,7 +652,7 @@ struct query *hostalloc(struct query *);
 int parsecmdline (int, char **, struct runctl *, struct query *);
 char *prependdir (const char *, const char *);
 unsigned char *MD5Digest (unsigned const char *);
-void hmac_md5 (const unsigned char *, size_t, const char *, size_t, unsigned char *, size_t);
+void hmac_md5 (const unsigned char *, size_t, const unsigned char *, size_t, unsigned char *, size_t);
 int POP3_auth_rpa(char *, char *, int socket);
 typedef RETSIGTYPE (*SIGHANDLERTYPE) (int);
 void deal_with_sigchld(void);
diff --git a/md5c.c b/md5c.c
index 545b088bf72c0ab35ffa352ae18755f43e1950a5..fd05ae2a8f7fc422b707cee15bf15f55ab2122ff 100644 (file)
--- a/md5c.c
+++ b/md5c.c
 #include <string.h>   /* memmove */
 #endif
 
+#include <inttypes.h>
+
 /*
  * Note: this code is harmless on little-endian machines.
  */
 static void byteReverse(unsigned char *buf, unsigned longs)
 {
-    uint32 t;
+    uint32_t t;
     do {
-       t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
+       t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
            ((unsigned) buf[1] << 8 | buf[0]);
-       *(uint32 *) buf = t;
+       *(uint32_t *) buf = t;
        buf += 4;
     } while (--longs);
 }
@@ -57,12 +59,12 @@ void MD5Init(struct MD5Context *ctx)
 void MD5Update(struct MD5Context *ctx, const void *buf_, unsigned len)
 {
     const unsigned char *buf = (const unsigned char *)buf_;
-    register uint32 t;
+    register uint32_t t;
 
     /* Update bitcount */
 
     t = ctx->bits[0];
-    if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
+    if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t)
        ctx->bits[1]++;         /* Carry from low to high */
     ctx->bits[1] += len >> 29;
 
@@ -80,7 +82,7 @@ void MD5Update(struct MD5Context *ctx, const void *buf_, unsigned len)
        }
        memmove(p, buf, t);
        byteReverse(ctx->in, 16);
-       MD5Transform(ctx->buf, (uint32 *) ctx->in);
+       MD5Transform(ctx->buf, (uint32_t *) ctx->in);
        buf += t;
        len -= t;
     }
@@ -89,7 +91,7 @@ void MD5Update(struct MD5Context *ctx, const void *buf_, unsigned len)
     while (len >= 64) {
        memmove(ctx->in, buf, 64);
        byteReverse(ctx->in, 16);
-       MD5Transform(ctx->buf, (uint32 *) ctx->in);
+       MD5Transform(ctx->buf, (uint32_t *) ctx->in);
        buf += 64;
        len -= 64;
     }
@@ -124,7 +126,7 @@ void MD5Final(void *digest, struct MD5Context *ctx)
        /* Two lots of padding:  Pad the first block to 64 bytes */
        memset(p, 0, count);
        byteReverse(ctx->in, 16);
-       MD5Transform(ctx->buf, (uint32 *) ctx->in);
+       MD5Transform(ctx->buf, (uint32_t *) ctx->in);
 
        /* Now fill the next block with 56 bytes */
        memset(ctx->in, 0, 56);
@@ -135,10 +137,10 @@ void MD5Final(void *digest, struct MD5Context *ctx)
     byteReverse(ctx->in, 14);
 
     /* Append length in bits and transform */
-    ((uint32 *) ctx->in)[14] = ctx->bits[0];
-    ((uint32 *) ctx->in)[15] = ctx->bits[1];
+    ((uint32_t *) ctx->in)[14] = ctx->bits[0];
+    ((uint32_t *) ctx->in)[15] = ctx->bits[1];
 
-    MD5Transform(ctx->buf, (uint32 *) ctx->in);
+    MD5Transform(ctx->buf, (uint32_t *) ctx->in);
     byteReverse((unsigned char *) ctx->buf, 4);
     memmove(digest, ctx->buf, 16);
     memset(ctx, 0, sizeof(ctx));       /* In case it's sensitive */
@@ -161,9 +163,9 @@ void MD5Final(void *digest, struct MD5Context *ctx)
  * reflect the addition of 16 longwords of new data.  MD5Update blocks
  * the data and converts bytes into longwords for this routine.
  */
-void MD5Transform(uint32 buf[4], uint32 const in[16])
+void MD5Transform(uint32_t buf[4], uint32_t const in[16])
 {
-    register uint32 a, b, c, d;
+    register uint32_t a, b, c, d;
 
     a = buf[0];
     b = buf[1];
diff --git a/smtp.c b/smtp.c
index 584f9ecef72cfe7c5efbd689dc31a6974a9896a6..611bad075dff7986ffe98a23d43768e005e6fed2 100644 (file)
--- a/smtp.c
+++ b/smtp.c
@@ -98,7 +98,7 @@ static void SMTP_auth(int sock, char smtp_mode, char *username, char *password,
                if (outlevel >= O_DEBUG)
                        report(stdout, GT_("Challenge decoded: %s\n"), b64buf);
                hmac_md5((unsigned char *)password, strlen(password),
-                        b64buf, strlen(b64buf), digest, sizeof(digest));
+                        (unsigned char *)b64buf, strlen(b64buf), digest, sizeof(digest));
                snprintf(tmp, sizeof(tmp),
                "%s %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
                username,  digest[0], digest[1], digest[2], digest[3],
index 5e93c6ca574c6c9163d4b025dbb0acc33a98f989..93962526d5db472ac8677e1a20e215c15459d864 100644 (file)
@@ -983,7 +983,7 @@ process_headers:
        MD5_CTX context;
 
        MD5Init(&context);
-       MD5Update(&context, msgblk.headers, strlen(msgblk.headers));
+       MD5Update(&context, (unsigned char *)msgblk.headers, strlen(msgblk.headers));
        MD5Final(ctl->digest, &context);
 
        if (!received_for && env_offs == -1 && !delivered_to)