From 8e4bfa7520c919ec2a7b00067c3348f0d1c73c8d Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Thu, 18 Mar 2010 23:29:22 +0100 Subject: Further type fixes. --- Makefile.am | 2 +- configure.ac | 6 +++--- cram.c | 8 ++++---- fetchmail.h | 8 ++++---- fm_md5.h | 41 +++++++++++++++++++++++++++++++++++++++++ gssapi.c | 2 +- md5.h | 34 ---------------------------------- md5c.c | 2 +- md5ify.c | 2 +- opie.c | 2 +- pop3.c | 2 +- rpa.c | 5 +++-- smbutil.c | 10 +++++----- smtp.c | 2 +- transact.c | 2 +- 15 files changed, 68 insertions(+), 60 deletions(-) create mode 100644 fm_md5.h delete mode 100644 md5.h diff --git a/Makefile.am b/Makefile.am index 488346d3..900ea59e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -61,7 +61,7 @@ TESTS+= t.regression endif fetchmail_SOURCES= fetchmail.h getopt.h \ - i18n.h kerberos.h md5.h mx.h netrc.h smtp.h \ + i18n.h kerberos.h fm_md5.h mx.h netrc.h smtp.h \ socket.h tunable.h \ socket.c getpass.c \ fetchmail.c env.c idle.c options.c daemon.c \ diff --git a/configure.ac b/configure.ac index 69e38390..6f47a32c 100644 --- a/configure.ac +++ b/configure.ac @@ -72,7 +72,7 @@ AC_TYPE_SIGNAL AC_CHECK_HEADERS([unistd.h termios.h termio.h sgtty.h stdarg.h \ sys/itimer.h fcntl.h sys/fcntl.h memory.h sys/wait.h \ arpa/inet.h arpa/nameser.h netinet/in.h net/socket.h netdb.h \ - sys/select.h sys/socket.h sys/time.h langinfo.h]) + sys/select.h sys/socket.h sys/time.h langinfo.h md5.h]) if test _$ac_cv_header_stdarg_h != _yes ; then AC_MSG_WARN([stdarg.h is not defined. Unsupported configuration, proceed at your own risk.]) fi @@ -502,7 +502,7 @@ AC_CACHE_CHECK([for getnameinfo],[fm_cv_getnameinfo],[ #include #endif #ifndef NULL -#define NULL ((void *)0) +#define NULL 0 #endif ], [getnameinfo(NULL,0, NULL,0, NULL, 0, 0);], [ fm_cv_getnameinfo=yes], @@ -791,7 +791,7 @@ then save_LIBS="$LIBS" for i in "" "-ldl" ; do LIBS="$LDFLAGS $save_LIBS $i" - AC_LINK_IFELSE([AC_LANG_PROGRAM(,[SSL_library_init()])],[found=1; break]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ],[SSL_library_init()])],[found=1; break]) done if test $found = 0 ; then AC_MSG_RESULT([error]) diff --git a/cram.c b/cram.c index 16591b8d..e71f0ecd 100644 --- a/cram.c +++ b/cram.c @@ -15,16 +15,16 @@ #include "socket.h" #include "i18n.h" -#include "md5.h" +#include "fm_md5.h" -void hmac_md5 (const char *password, size_t pass_len, +void hmac_md5 (const unsigned char *password, size_t pass_len, const char *challenge, size_t chal_len, unsigned char *response, size_t resp_len) { int i; unsigned char ipad[64]; unsigned char opad[64]; - char hash_passwd[16]; + unsigned char hash_passwd[16]; MD5_CTX ctx; @@ -110,7 +110,7 @@ int do_cram_md5 (int sock, const char *command, struct query *ctl, const char *s * (including angle-brackets). */ - hmac_md5(ctl->password, strlen(ctl->password), + hmac_md5((unsigned char *)ctl->password, strlen(ctl->password), msg_id, strlen (msg_id), response, sizeof (response)); diff --git a/fetchmail.h b/fetchmail.h index 51562933..a786caf2 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -324,7 +324,7 @@ struct query char *smtpaddress; /* address to force in RCPT TO */ char *smtpname; /* full RCPT TO name, including domain */ struct idlist *antispam; /* list of listener's antispam response */ - char *mda; /* local MDA to pass mail to */ + const char *mda; /* local MDA to pass mail to */ char *bsmtp; /* BSMTP output file */ char listener; /* what's the listener's wire protocol? */ #define SMTP_MODE 'S' @@ -384,7 +384,7 @@ struct query /* internal use -- per-message state */ int mimemsg; /* bitmask indicating MIME body-type */ - char digest[DIGESTLEN]; /* md5 digest buffer */ + unsigned char digest[DIGESTLEN]; /* md5 digest buffer */ /* internal use -- housekeeping */ struct query *next; /* next query control block in chain */ @@ -651,8 +651,8 @@ extern char currentwd[1024], rcfiledir[1024]; struct query *hostalloc(struct query *); int parsecmdline (int, char **, struct runctl *, struct query *); char *prependdir (const char *, const char *); -char *MD5Digest (unsigned const char *); -void hmac_md5 (const char *, size_t, const char *, size_t, unsigned char *, size_t); +unsigned char *MD5Digest (unsigned const char *); +void hmac_md5 (const unsigned char *, size_t, const 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/fm_md5.h b/fm_md5.h new file mode 100644 index 00000000..6fccc526 --- /dev/null +++ b/fm_md5.h @@ -0,0 +1,41 @@ +#ifndef MD5_H +#define MD5_H + +#include "config.h" + +#include + +#ifdef HAVE_MD5_H +#include +#else + +#ifndef HEADER_MD5_H +/* Try to avoid clashes with OpenSSL */ +#define HEADER_MD5_H +#endif + + +#if SIZEOF_INT == 4 +typedef unsigned int uint32; +#else +typedef unsigned long int uint32; +#endif + +struct MD5Context { + uint32 buf[4]; + uint32 bits[2]; + unsigned char in[64]; +}; + +void MD5Init(struct MD5Context *context); +void MD5Update(struct MD5Context *context, const void *buf, unsigned len); +void MD5Final(void *digest, struct MD5Context *context); +void MD5Transform(uint32 buf[], uint32 const in[]); + +/* + * This is needed to make RSAREF happy on some MS-DOS compilers. + */ +typedef struct MD5Context MD5_CTX; + +#endif +#endif /* !MD5_H */ diff --git a/gssapi.c b/gssapi.c index 4f8e766c..37c5a6af 100644 --- a/gssapi.c +++ b/gssapi.c @@ -15,7 +15,7 @@ #include "socket.h" #include "i18n.h" -#include "md5.h" +#include "fm_md5.h" #include #include /* for htonl/ntohl */ diff --git a/md5.h b/md5.h deleted file mode 100644 index 83b748c4..00000000 --- a/md5.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef MD5_H -#define MD5_H -#ifndef HEADER_MD5_H -/* Try to avoid clashes with OpenSSL */ -#define HEADER_MD5_H -#endif - -#include "config.h" - -#if SIZEOF_INT == 4 -typedef unsigned int uint32; -#else -typedef unsigned long int uint32; -#endif - -struct MD5Context { - uint32 buf[4]; - uint32 bits[2]; - unsigned char in[64]; -}; - -void MD5Init(struct MD5Context *context); -void MD5Update(struct MD5Context *context, const void *buf, unsigned len); -void MD5Final(void *digest, struct MD5Context *context); -void MD5Transform(uint32 buf[], uint32 const in[]); - -char *MD5Digest (unsigned const char *s); - -/* - * This is needed to make RSAREF happy on some MS-DOS compilers. - */ -typedef struct MD5Context MD5_CTX; - -#endif /* !MD5_H */ diff --git a/md5c.c b/md5c.c index 61fd2fe7..545b088b 100644 --- a/md5c.c +++ b/md5c.c @@ -16,7 +16,7 @@ */ #include "config.h" -#include "md5.h" +#include "fm_md5.h" #ifdef HAVE_STRING_H #include /* memmove */ #endif diff --git a/md5ify.c b/md5ify.c index 8d5c8807..5affe316 100644 --- a/md5ify.c +++ b/md5ify.c @@ -17,7 +17,7 @@ #include #endif -#include "md5.h" +#include "fm_md5.h" char * MD5Digest (unsigned const char *s) diff --git a/opie.c b/opie.c index 94fd59b4..06756121 100644 --- a/opie.c +++ b/opie.c @@ -15,7 +15,7 @@ #include "socket.h" #include "i18n.h" -#include "md5.h" +#include "fm_md5.h" #ifdef OPIE_ENABLE #ifdef __cplusplus diff --git a/pop3.c b/pop3.c index 70a91dd5..d9bc0000 100644 --- a/pop3.c +++ b/pop3.c @@ -690,7 +690,7 @@ static int pop3_getauth(int sock, struct query *ctl, char *greeting) msg = (char *)xmalloc((end-start+1) + strlen(ctl->password) + 1); strcpy(msg,start); strcat(msg,ctl->password); - strcpy(ctl->digest, MD5Digest((unsigned char *)msg)); + strcpy((char *)ctl->digest, (char *)MD5Digest((unsigned char *)msg)); free(msg); ok = gen_transact(sock, "APOP %s %s", ctl->remotename, ctl->digest); diff --git a/rpa.c b/rpa.c index a8091897..925718a7 100644 --- a/rpa.c +++ b/rpa.c @@ -21,10 +21,11 @@ #include #include #include +#include #include "socket.h" #include "fetchmail.h" -#include "md5.h" +#include "fm_md5.h" #include "i18n.h" #ifdef TESTMODE @@ -114,7 +115,7 @@ int POP3_auth_rpa (char *userid, char *passphrase, int socket) char buf [POPBUFSIZE]; char *bufp; int status,aulin,kuslin; - char* stdec[4] = { N_("Success") , + const char* stdec[4] = { N_("Success") , N_("Restricted user (something wrong with account)") , N_("Invalid userid or passphrase") , N_("Deity error") }; diff --git a/smbutil.c b/smbutil.c index fd239d9c..a26b3496 100644 --- a/smbutil.c +++ b/smbutil.c @@ -84,12 +84,12 @@ static void dumpRaw(FILE *fp, unsigned char *buf, size_t len) /* helper macro to destructively resize buffers; assumes that bufsiz * is initialized to 0 if buf is unallocated! */ -#define allocbuf(buf, bufsiz, need) do { \ +#define allocbuf(buf, bufsiz, need, type) do { \ if (!buf || (need) > (bufsiz)) \ { \ (bufsiz) = ((need) < 1024) ? 1024 : (need); \ xfree(buf); \ - (buf) = xmalloc(bufsiz); \ + (buf) = (type)xmalloc(bufsiz); \ } \ } while (0); @@ -101,7 +101,7 @@ static char *unicodeToString(char *p, size_t len) static char *buf; static size_t bufsiz; - allocbuf(buf, bufsiz, len + 1); + allocbuf(buf, bufsiz, len + 1, char *); for (i=0; i= O_DEBUG) report(stdout, GT_("Challenge decoded: %s\n"), b64buf); - hmac_md5(password, strlen(password), + hmac_md5((unsigned char *)password, strlen(password), 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", diff --git a/transact.c b/transact.c index 5201ceef..5e93c6ca 100644 --- a/transact.c +++ b/transact.c @@ -29,7 +29,7 @@ #endif #include #include -#include "md5.h" +#include "fm_md5.h" #include "i18n.h" #include "socket.h" -- cgit v1.2.3