From 4be6b90403ad4e3f1dd4da297291eb1bf301bebc Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 9 Apr 2002 00:04:05 +0000 Subject: Various cleanup patches. svn path=/trunk/; revision=3612 --- Makefile.in | 7 ++----- NEWS | 6 ++++++ acconfig.h | 3 --- configure.in | 3 +-- driver.c | 4 ++++ fetchmail.h | 2 +- odmr.c | 3 +++ smtp.c | 57 ++++++++++++++++++++++++++++++++++++++------------------- 8 files changed, 55 insertions(+), 30 deletions(-) diff --git a/Makefile.in b/Makefile.in index 05b083ac..e479b9ae 100644 --- a/Makefile.in +++ b/Makefile.in @@ -4,7 +4,7 @@ # So just uncomment all the lines marked QNX. PACKAGE = fetchmail -VERSION = 5.9.11 +VERSION = 6.0.0 # Ultrix 2.2 make doesn't expand the value of VPATH. srcdir = @srcdir@ @@ -44,9 +44,6 @@ defines = $(DEFS) LOADLIBS = @LIBS@ @INTLLIBS@ @LEXLIB@ # LOADLIBS = -lsocket3r -lunix3r # QNX -# Any extra object files your system needs. -extras = @LIBOBJS@ - # Extra sources/objects for library functions not provided on the host system. EXTRASRC = @EXTRASRC@ # EXTRASRC = $(srcdir)/strcasecmp.c $(srcdir)/alloca.c # QNX @@ -98,7 +95,7 @@ protobjs = rcfile_y.o rcfile_l.o socket.o getpass.o pop2.o pop3.o imap.o \ report.o unmime.o conf.o checkalias.o smbdes.o smbencrypt.o smbmd4.o \ smbutil.o ipv6-connect.o lock.o -objs = $(protobjs) $(extras) $(EXTRAOBJ) +objs = $(protobjs) $(EXTRAOBJ) srcs = $(srcdir)/socket.c $(srcdir)/getpass.c $(srcdir)/pop2.c \ $(srcdir)/pop3.c $(srcdir)/imap.c $(srcdir)/etrn.c \ diff --git a/NEWS b/NEWS index b0ad61a0..92fa2062 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,12 @@ (The `lines' figures total .c, .h, .l, and .y files under version control.) +* Brian Grayson's patch enabling compilation under AIX 4.1. +* Federico G. Schwindt's patch to support BSD ELF systems. +* Fix to Sunil Shetye's attributes patch. +* Scott Bronson's patch to reap zombies after an MDA core dump. +* New Japanese translation file. + fetchmail-5.9.11 (Mon Apr 1 17:09:13 EST 2002), 21597 lines: * Updated Turkish and Japanese translations. diff --git a/acconfig.h b/acconfig.h index 1c0a046d..7fd0753e 100644 --- a/acconfig.h +++ b/acconfig.h @@ -18,9 +18,6 @@ /* Define as 1 if you have catgets and don't want to use GNU gettext. */ #undef HAVE_CATGETS -/* Define if you have GNU's getopt family of functions. */ -#undef HAVE_GETOPT_LONG - /* Define as 1 if you have gettext and don't want to use GNU gettext. */ #undef HAVE_GETTEXT diff --git a/configure.in b/configure.in index 3b4d11dc..63aa3931 100644 --- a/configure.in +++ b/configure.in @@ -40,7 +40,6 @@ AC_PROG_YACC AC_SUBST(CPFLAGS) AC_SUBST(CEFLAGS) AC_SUBST(LDEFLAGS) -AC_SUBST(LIBOBJS) # Check for LynxOS special case: -lbsd needed (at least on 2.3.0) and -s # not working. @@ -411,7 +410,7 @@ then AC_DEFINE(HEIMDAL) AC_DEFINE(KERBEROS_V5) CEFLAGS="$CEFLAGS -I/usr/include/kerberosV" - LIBS="$LIBS -lasn1 -lkrb5 -lcom_err" + LIBS="$LIBS -lasn1 -lkrb5 -lcom_err -lkafs" else if test "$with_kerberos5" != "yes" then diff --git a/driver.c b/driver.c index b11d7536..2eda23ef 100644 --- a/driver.c +++ b/driver.c @@ -25,6 +25,9 @@ #endif #include #include +#ifdef HAVE_SYS_WAIT_H +#include +#endif #ifdef HAVE_NET_SOCKET_H #include @@ -753,6 +756,7 @@ const int maxfetch; /* maximum number of messages to fetch */ signal(SIGPIPE, SIG_IGN); report(stdout, GT_("SIGPIPE thrown from an MDA or a stream socket error\n")); + wait(0); err = PS_SOCKET; goto cleanUp; } diff --git a/fetchmail.h b/fetchmail.h index a3bf4913..a2e7b10a 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -393,7 +393,7 @@ extern char *sdps_envto; /* from /usr/include/sys/cdefs.h */ #if !defined __GNUC__ || __GNUC__ < 2 -# define __attribute__(xyz)» /* Ignore. */ +# define __attribute__(xyz) /* Ignore. */ #endif /* error.c: Error reporting */ diff --git a/odmr.c b/odmr.c index 3dcb3e62..76891681 100644 --- a/odmr.c +++ b/odmr.c @@ -20,6 +20,9 @@ #ifdef HAVE_NET_SELECT_H /* AIX needs this */ #include #endif +#ifdef HAVE_SYS_SELECT_H /* AIX 4.1, at least, needs this */ +#include +#endif #include #include #include diff --git a/smtp.c b/smtp.c index 618b294d..021c868c 100644 --- a/smtp.c +++ b/smtp.c @@ -57,21 +57,29 @@ int SMTP_helo(int sock,const char *host) return ok; } +static void SMTP_auth_error(int sock, char *msg) +{ + SockPrintf(sock, "*\r\n"); + SockRead(sock, smtp_response, sizeof(smtp_response) - 1); + if (outlevel >= O_MONITOR) report(stdout, msg); +} + static void SMTP_auth(int sock, char *username, char *password, char *buf) /* ESMTP Authentication support for fetchmail by Wojciech Polak */ -{ +{ int c; char *p = 0; char b64buf[512]; char tmp[512]; + if (!username || !password) return; + memset(b64buf, 0, sizeof(b64buf)); memset(tmp, 0, sizeof(tmp)); if (strstr(buf, "CRAM-MD5")) { unsigned char digest[16]; - static char ascii_digest[33]; - memset(digest, 0, 16); + memset(digest, 0, sizeof(digest)); if (outlevel >= O_MONITOR) report(stdout, GT_("ESMTP CRAM-MD5 Authentication...\n")); @@ -80,28 +88,31 @@ static void SMTP_auth(int sock, char *username, char *password, char *buf) strncpy(tmp, smtp_response, sizeof(tmp)); if (strncmp(tmp, "334 ", 4)) { /* Server rejects AUTH */ - SockPrintf(sock, "*\r\n"); - SockRead(sock, smtp_response, sizeof(smtp_response) - 1); - if (outlevel >= O_MONITOR) - report(stdout, GT_("Server rejected the AUTH command.\n")); + SMTP_auth_error(sock, GT_("Server rejected the AUTH command.\n")); return; } p = strchr(tmp, ' '); p++; - from64tobits(b64buf, p, sizeof(b64buf)); + /* (hmh) from64tobits will not NULL-terminate strings! */ + if (from64tobits(b64buf, p, sizeof(b64buf) - 1) <= 0) { + SMTP_auth_error(sock, GT_("Bad base64 reply from server.\n")); + return; + } if (outlevel >= O_DEBUG) report(stdout, GT_("Challenge decoded: %s\n"), b64buf); hmac_md5(password, strlen(password), - b64buf, strlen(b64buf), digest, sizeof(digest)); - for (c = 0; c < 16; c++) - sprintf(ascii_digest + 2 * c, "%02x", digest[c]); + b64buf, strlen(b64buf), digest, sizeof(digest)); #ifdef HAVE_SNPRINTF snprintf(tmp, sizeof(tmp), #else sprintf(tmp, #endif /* HAVE_SNPRINTF */ - "%s %s", username, ascii_digest); + "%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], + digest[4], digest[5], digest[6], digest[7], digest[8], + digest[9], digest[10], digest[11], digest[12], digest[13], + digest[14], digest[15]); to64frombits(b64buf, tmp, strlen(tmp)); SockPrintf(sock, "%s\r\n", b64buf); @@ -136,23 +147,31 @@ static void SMTP_auth(int sock, char *username, char *password, char *buf) strncpy(tmp, smtp_response, sizeof(tmp)); if (strncmp(tmp, "334 ", 4)) { /* Server rejects AUTH */ - SockPrintf(sock, "*\r\n"); - SockRead(sock, smtp_response, sizeof(smtp_response) - 1); - if (outlevel >= O_MONITOR) - report(stdout, GT_("Server rejected the AUTH command.\n")); + SMTP_auth_error(sock, GT_("Server rejected the AUTH command.\n")); return; } p = strchr(tmp, ' '); p++; - from64tobits(b64buf, p, sizeof(b64buf)); + if (from64tobits(b64buf, p, sizeof(b64buf) - 1) <= 0) { + SMTP_auth_error(sock, GT_("Bad base64 reply from server.\n")); + return; + } to64frombits(b64buf, username, strlen(username)); SockPrintf(sock, "%s\r\n", b64buf); SockRead(sock, smtp_response, sizeof(smtp_response) - 1); strncpy(tmp, smtp_response, sizeof(tmp)); p = strchr(tmp, ' '); + if (!p) { + SMTP_auth_error(sock, GT_("Bad base64 reply from server.\n")); + return; + } p++; - from64tobits(b64buf, p, sizeof(b64buf)); + memset(b64buf, 0, sizeof(b64buf)); + if (from64tobits(b64buf, p, sizeof(b64buf) - 1) <= 0) { + SMTP_auth_error(sock, GT_("Bad base64 reply from server.\n")); + return; + } to64frombits(b64buf, password, strlen(password)); SockPrintf(sock, "%s\r\n", b64buf); SMTP_ok(sock); @@ -164,7 +183,7 @@ int SMTP_ehlo(int sock, const char *host, char *name, char *password, int *opt) /* send a "EHLO" message to the SMTP listener, return extension status bits */ { struct opt *hp; - char auth_response[256]; + char auth_response[511]; SockPrintf(sock,"%cHLO %s\r\n", (smtp_mode == 'S') ? 'E' : smtp_mode, host); if (outlevel >= O_MONITOR) -- cgit v1.2.3