summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile2
-rw-r--r--src/OS/Makefile-Base6
-rw-r--r--src/OS/os.c-Linux2
-rw-r--r--src/OS/os.h-FreeBSD4
-rw-r--r--src/OS/os.h-Linux3
-rw-r--r--src/OS/os.h-OpenBSD28
-rw-r--r--src/exim_monitor/em_globals.c2
-rw-r--r--src/exim_monitor/em_log.c2
-rw-r--r--src/exim_monitor/em_main.c2
-rw-r--r--src/exim_monitor/em_menu.c2
-rw-r--r--src/exim_monitor/em_queue.c2
-rw-r--r--src/exim_monitor/em_version.c2
-rwxr-xr-xsrc/scripts/Configure-Makefile2
-rwxr-xr-xsrc/scripts/MakeLinks2
-rwxr-xr-xsrc/scripts/reversion4
-rw-r--r--src/src/EDITME3
-rw-r--r--src/src/acl.c4
-rw-r--r--src/src/auths/call_pam.c2
-rw-r--r--src/src/auths/cram_md5.c2
-rw-r--r--src/src/auths/cyrus_sasl.c2
-rw-r--r--src/src/auths/dovecot.c2
-rw-r--r--src/src/auths/get_data.c2
-rw-r--r--src/src/auths/get_no64_data.c2
-rw-r--r--src/src/auths/gsasl_exim.c2
-rw-r--r--src/src/auths/heimdal_gssapi.c2
-rw-r--r--src/src/auths/md5.c2
-rw-r--r--src/src/auths/plaintext.c2
-rw-r--r--src/src/auths/spa.c2
-rw-r--r--src/src/auths/tls.c2
-rw-r--r--src/src/auths/xtextencode.c2
-rw-r--r--src/src/base64.c2
-rw-r--r--src/src/buildconfig.c32
-rw-r--r--src/src/config.h.defaults2
-rw-r--r--src/src/dane-openssl.c2
-rw-r--r--src/src/dbfn.c2
-rw-r--r--src/src/dbstuff.h10
-rw-r--r--src/src/dcc.c2
-rw-r--r--src/src/debug.c2
-rw-r--r--src/src/deliver.c142
-rw-r--r--src/src/dkim.c28
-rw-r--r--src/src/dkim.h2
-rw-r--r--src/src/dkim_transport.c18
-rw-r--r--src/src/dmarc.c31
-rw-r--r--src/src/drtables.c2
-rw-r--r--src/src/exigrep.src2
-rw-r--r--src/src/exim.c145
-rw-r--r--src/src/exim.h10
-rw-r--r--src/src/exim_dbmbuild.c2
-rw-r--r--src/src/exim_dbutil.c2
-rw-r--r--src/src/eximstats.src2
-rw-r--r--src/src/exipick.src7
-rw-r--r--src/src/expand.c43
-rw-r--r--src/src/filter.c4
-rw-r--r--src/src/functions.h7
-rw-r--r--src/src/hash.c4
-rw-r--r--src/src/hash.h2
-rw-r--r--src/src/host.c2
-rw-r--r--src/src/imap_utf7.c3
-rw-r--r--src/src/ip.c54
-rw-r--r--src/src/local_scan.h2
-rw-r--r--src/src/log.c8
-rw-r--r--src/src/lookups/dbmdb.c2
-rw-r--r--src/src/lookups/dnsdb.c2
-rw-r--r--src/src/lookups/ibase.c2
-rw-r--r--src/src/lookups/ldap.c2
-rw-r--r--src/src/lookups/lf_functions.h2
-rw-r--r--src/src/lookups/lf_quote.c2
-rw-r--r--src/src/lookups/lf_sqlperform.c4
-rw-r--r--src/src/lookups/lmdb.c2
-rw-r--r--src/src/lookups/lsearch.c2
-rw-r--r--src/src/lookups/mysql.c58
-rw-r--r--src/src/lookups/nisplus.c2
-rw-r--r--src/src/lookups/pgsql.c2
-rw-r--r--src/src/lookups/redis.c2
-rw-r--r--src/src/lookups/sqlite.c2
-rw-r--r--src/src/macro_predef.c25
-rw-r--r--src/src/macro_predef.h2
-rw-r--r--src/src/macros.h12
-rw-r--r--src/src/malware.c6
-rw-r--r--src/src/match.c2
-rw-r--r--src/src/mime.c2
-rw-r--r--src/src/moan.c4
-rw-r--r--src/src/mytypes.h2
-rw-r--r--src/src/os.c2
-rw-r--r--src/src/parse.c4
-rw-r--r--src/src/pdkim/Makefile1
-rw-r--r--src/src/pdkim/crypt_ver.h2
-rw-r--r--src/src/pdkim/pdkim.c8
-rw-r--r--src/src/pdkim/pdkim.h9
-rw-r--r--src/src/pdkim/pdkim_hash.h2
-rw-r--r--src/src/pdkim/signing.c2
-rw-r--r--src/src/pdkim/signing.h2
-rw-r--r--src/src/perl.c1
-rw-r--r--src/src/queue.c15
-rw-r--r--src/src/rda.c2
-rw-r--r--src/src/readconf.c44
-rw-r--r--src/src/receive.c13
-rw-r--r--src/src/regex.c2
-rw-r--r--src/src/retry.c2
-rw-r--r--src/src/rewrite.c4
-rw-r--r--src/src/rfc2047.c2
-rw-r--r--src/src/route.c2
-rw-r--r--src/src/routers/accept.c2
-rw-r--r--src/src/routers/dnslookup.c2
-rw-r--r--src/src/routers/ipliteral.c2
-rw-r--r--src/src/routers/iplookup.c2
-rw-r--r--src/src/routers/manualroute.c2
-rw-r--r--src/src/routers/queryprogram.c2
-rw-r--r--src/src/routers/redirect.c2
-rw-r--r--src/src/routers/rf_change_domain.c6
-rw-r--r--src/src/routers/rf_get_errors_address.c2
-rw-r--r--src/src/routers/rf_get_munge_headers.c2
-rw-r--r--src/src/routers/rf_queue_add.c2
-rw-r--r--src/src/sieve.c2
-rw-r--r--src/src/smtp_in.c22
-rw-r--r--src/src/smtp_out.c12
-rw-r--r--src/src/spam.c2
-rw-r--r--src/src/spf.c2
-rw-r--r--src/src/spool_in.c6
-rw-r--r--src/src/spool_mbox.c2
-rw-r--r--src/src/spool_out.c2
-rw-r--r--src/src/std-crypto.c1
-rw-r--r--src/src/store.c2
-rw-r--r--src/src/string.c20
-rw-r--r--src/src/structs.h2
-rw-r--r--src/src/tls-gnu.c2
-rw-r--r--src/src/tls-openssl.c2
-rw-r--r--src/src/tls.c2
-rw-r--r--src/src/tlscert-gnu.c2
-rw-r--r--src/src/tlscert-openssl.c6
-rw-r--r--src/src/tod.c2
-rw-r--r--src/src/transport.c4
-rw-r--r--src/src/transports/appendfile.c156
-rw-r--r--src/src/transports/appendfile.h2
-rw-r--r--src/src/transports/autoreply.c2
-rw-r--r--src/src/transports/lmtp.c2
-rw-r--r--src/src/transports/pipe.c2
-rw-r--r--src/src/transports/queuefile.c1
-rw-r--r--src/src/transports/smtp.c85
-rw-r--r--src/src/transports/smtp_socks.c4
-rw-r--r--src/src/transports/tf_maildir.c2
-rw-r--r--src/src/utf8.c2
-rw-r--r--src/src/verify.c31
-rw-r--r--src/src/version.c1
144 files changed, 772 insertions, 573 deletions
diff --git a/src/Makefile b/src/Makefile
index b262a7b53..958306292 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -2,7 +2,7 @@
# appropriate links, and then creating and running the main makefile in that
# directory.
-# Copyright (c) University of Cambridge, 1995 - 2015
+# Copyright (c) University of Cambridge, 1995 - 2017
# See the file NOTICE for conditions of use and distribution.
# IRIX make uses the shell that is in the SHELL variable, which often defaults
diff --git a/src/OS/Makefile-Base b/src/OS/Makefile-Base
index 67ac082ba..d64ed549f 100644
--- a/src/OS/Makefile-Base
+++ b/src/OS/Makefile-Base
@@ -5,7 +5,7 @@
# optional, Local/* files at the front of this file, to create Makefile in the
# build directory.
#
-# Copyright (c) The Exim Maintainers 2016
+# Copyright (c) The Exim Maintainers 2017
SHELL = $(MAKE_SHELL)
SCRIPTS = ../scripts
@@ -135,6 +135,7 @@ OBJ_MACRO = macro_predef.o \
macro-manualroute.o macro-queryprogram.o macro-redirect.o \
macro-auth-spa.o macro-cram_md5.o macro-cyrus_sasl.o macro-dovecot.o macro-gsasl_exim.o \
macro-heimdal_gssapi.o macro-plaintext.o macro-spa.o macro-tls.o\
+ macro-dkim.o
$(OBJ_MACRO): $(MACRO_HSRC)
@@ -222,6 +223,9 @@ macro-spa.o : auths/spa.c
macro-tls.o: auths/tls.c
@echo "$(CC) -DMACRO_PREDEF auths/tls.c"
$(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ auths/tls.c
+macro-dkim.o: dkim.c
+ @echo "$(CC) -DMACRO_PREDEF dkim.c"
+ $(FE)$(CC) -c $(CFLAGS) -DMACRO_PREDEF $(INCLUDE) -o $@ dkim.c
macro_predef: $(OBJ_MACRO)
@echo "$(LNCC) -o $@"
diff --git a/src/OS/os.c-Linux b/src/OS/os.c-Linux
index dd65c8b39..a10bc7d25 100644
--- a/src/OS/os.c-Linux
+++ b/src/OS/os.c-Linux
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1997 - 2016 */
+/* Copyright (c) University of Cambridge 1997 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Linux-specific code. This is concatenated onto the generic
diff --git a/src/OS/os.h-FreeBSD b/src/OS/os.h-FreeBSD
index 3a06e766e..8b1af396a 100644
--- a/src/OS/os.h-FreeBSD
+++ b/src/OS/os.h-FreeBSD
@@ -1,4 +1,7 @@
/* Exim: OS-specific C header file for FreeBSD */
+/* Copyright (c) University of Cambridge 2017 */
+/* See the file NOTICE for conditions of use and distribution. */
+
#include <sys/types.h>
@@ -48,6 +51,7 @@ extern ssize_t os_sendfile(int, int, off_t *, size_t);
/* TCP_FASTOPEN support. There does not seems to be a
MSG_FASTOPEN defined yet... */
+#define EXIM_TFO_PROBE
#include <netinet/tcp.h> /* for TCP_FASTOPEN */
#include <sys/socket.h> /* for MSG_FASTOPEN */
diff --git a/src/OS/os.h-Linux b/src/OS/os.h-Linux
index f6d35772b..88c4d9117 100644
--- a/src/OS/os.h-Linux
+++ b/src/OS/os.h-Linux
@@ -1,4 +1,7 @@
/* Exim: OS-specific C header file for Linux */
+/* Copyright (c) University of Cambridge 2017 */
+/* See the file NOTICE for conditions of use and distribution. */
+
/* Some old systems we've received bug-reports for have a <limits.h> which
does not pull in <features.h>. Best to just pull it in now and have done
diff --git a/src/OS/os.h-OpenBSD b/src/OS/os.h-OpenBSD
index 5d55a967e..81ed4870b 100644
--- a/src/OS/os.h-OpenBSD
+++ b/src/OS/os.h-OpenBSD
@@ -1,4 +1,7 @@
/* Exim: OS-specific C header file for OpenBSD */
+/* Copyright (c) University of Cambridge 2017 */
+/* See the file NOTICE for conditions of use and distribution. */
+
#define HAVE_BSD_GETLOADAVG
#define HAVE_MMAP
@@ -10,7 +13,7 @@
if the version released is past that point. */
#include <sys/param.h>
#if OpenBSD >= 201405
-#define NOT_HAVE_ARC4RANDOM_STIR
+# define NOT_HAVE_ARC4RANDOM_STIR
#endif
typedef struct flock flock_t;
@@ -27,4 +30,27 @@ typedef struct __res_state *res_state;
# define EPROTO 71
#endif
+/* We need to force this; the automatic in buildconfig.c gets %ld */
+#ifdef OFF_T_FMT
+# undef OFF_T_FMT
+# undef LONGLONG_T
+#endif
+#define OFF_T_FMT "%lld"
+#define LONGLONG_T long long int
+
+#ifdef PID_T_FMT
+# undef PID_T_FMT
+#endif
+#define PID_T_FMT "%d"
+
+#ifdef INO_T_FMT
+# undef INO_T_FMT
+#endif
+#define INO_T_FMT "%llu"
+
+#ifdef TIME_T_FMT
+# undef TIME_T_FMT
+#endif
+#define TIME_T_FMT "%lld"
+
/* End */
diff --git a/src/exim_monitor/em_globals.c b/src/exim_monitor/em_globals.c
index 46ad834da..43d1bbceb 100644
--- a/src/exim_monitor/em_globals.c
+++ b/src/exim_monitor/em_globals.c
@@ -2,7 +2,7 @@
* Exim Monitor *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/exim_monitor/em_log.c b/src/exim_monitor/em_log.c
index 73aa0e567..69e63533c 100644
--- a/src/exim_monitor/em_log.c
+++ b/src/exim_monitor/em_log.c
@@ -2,7 +2,7 @@
* Exim Monitor *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* This module contains code for scanning the main log,
diff --git a/src/exim_monitor/em_main.c b/src/exim_monitor/em_main.c
index 00471ce3d..09b754b58 100644
--- a/src/exim_monitor/em_main.c
+++ b/src/exim_monitor/em_main.c
@@ -2,7 +2,7 @@
* Exim Monitor *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/exim_monitor/em_menu.c b/src/exim_monitor/em_menu.c
index 935e82687..6cd009d2b 100644
--- a/src/exim_monitor/em_menu.c
+++ b/src/exim_monitor/em_menu.c
@@ -2,7 +2,7 @@
* Exim Monitor *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/exim_monitor/em_queue.c b/src/exim_monitor/em_queue.c
index e6b1e91d9..7d231530c 100644
--- a/src/exim_monitor/em_queue.c
+++ b/src/exim_monitor/em_queue.c
@@ -2,7 +2,7 @@
* Exim Monitor *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2009 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/exim_monitor/em_version.c b/src/exim_monitor/em_version.c
index 0279654ac..a2edbfe8a 100644
--- a/src/exim_monitor/em_version.c
+++ b/src/exim_monitor/em_version.c
@@ -2,7 +2,7 @@
* Exim Monitor *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2009 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#include "mytypes.h"
diff --git a/src/scripts/Configure-Makefile b/src/scripts/Configure-Makefile
index 648960e44..2af192721 100755
--- a/src/scripts/Configure-Makefile
+++ b/src/scripts/Configure-Makefile
@@ -6,7 +6,7 @@ export LC_ALL=C
# just got too horrendous to get it right in "make", because of the optionally
# existing configuration files.
#
-# Copyright (c) The Exim Maintainers 2016
+# Copyright (c) The Exim Maintainers 2017
# First off, get the OS type, and check that there is a make file for it.
diff --git a/src/scripts/MakeLinks b/src/scripts/MakeLinks
index 22e5a4bd7..770591dc8 100755
--- a/src/scripts/MakeLinks
+++ b/src/scripts/MakeLinks
@@ -3,7 +3,7 @@
# Script to build links for all the exim source files from the system-
# specific build directory. It should be run from within that directory.
#
-# Copyright (c) The Exim Maintainers 2016
+# Copyright (c) The Exim Maintainers 2017
test ! -d ../src && \
echo "*** $0 should be run in a system-specific subdirectory." && \
diff --git a/src/scripts/reversion b/src/scripts/reversion
index 45755c084..c82d9c0ac 100755
--- a/src/scripts/reversion
+++ b/src/scripts/reversion
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (c) The Exim Maintainers 2016
+# Copyright (c) The Exim Maintainers 2017
set -e
LC_ALL=C
@@ -96,7 +96,7 @@ if [ ".${SOURCE_DATE_EPOCH:-}" != "." ]; then
# builds without it causing any problems: nothing really cares about timezone.
# GNU date: "date -d @TS"
# BSD date: "date -r TS"
- exim_build_date_override="$(date -u -d "@${SOURCE_DATE_EPOCH}" "$fmt" 2>/dev/null | date -u -r "${SOURCE_DATE_EPOCH}" "$fmt" 2>/dev/null)"
+ exim_build_date_override="$(date -u -d "@${SOURCE_DATE_EPOCH}" "$fmt" 2>/dev/null || date -u -r "${SOURCE_DATE_EPOCH}" "$fmt" 2>/dev/null)"
fi
( echo '# automatically generated file - see ../scripts/reversion'
diff --git a/src/src/EDITME b/src/src/EDITME
index e604acd8b..72e26ce0e 100644
--- a/src/src/EDITME
+++ b/src/src/EDITME
@@ -258,7 +258,7 @@ TRANSPORT_SMTP=yes
# you perform upgrades and revert them. You should consider the benefit of
# embedding the Exim version number into LOOKUP_MODULE_DIR, so that you can
# maintain two concurrent sets of modules.
-#
+#
# *BEWARE*: ability to modify the files in LOOKUP_MODULE_DIR is equivalent to
# the ability to modify the Exim binary, which is often setuid root! The Exim
# developers only intend this functionality be used by OS software packagers
@@ -311,6 +311,7 @@ LOOKUP_DNSDB=yes
# LOOKUP_IBASE=yes
# LOOKUP_LDAP=yes
# LOOKUP_MYSQL=yes
+# LOOKUP_MYSQL_PC=mariadb
# LOOKUP_NIS=yes
# LOOKUP_NISPLUS=yes
# LOOKUP_ORACLE=yes
diff --git a/src/src/acl.c b/src/src/acl.c
index 79feb5f68..640989997 100644
--- a/src/src/acl.c
+++ b/src/src/acl.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Code for handling Access Control Lists (ACLs) */
@@ -3931,7 +3931,7 @@ if (acl_level == 0)
}
else ss = s;
-while (isspace(*ss))ss++;
+while (isspace(*ss)) ss++;
/* If we can't find a named ACL, the default is to parse it as an inline one.
(Unless it begins with a slash; non-existent files give rise to an error.) */
diff --git a/src/src/auths/call_pam.c b/src/src/auths/call_pam.c
index a5cbec3ed..74d492792 100644
--- a/src/src/auths/call_pam.c
+++ b/src/src/auths/call_pam.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
diff --git a/src/src/auths/cram_md5.c b/src/src/auths/cram_md5.c
index b9e57c1e9..3f80bd674 100644
--- a/src/src/auths/cram_md5.c
+++ b/src/src/auths/cram_md5.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/auths/cyrus_sasl.c b/src/src/auths/cyrus_sasl.c
index cbf244633..afbeb81e2 100644
--- a/src/src/auths/cyrus_sasl.c
+++ b/src/src/auths/cyrus_sasl.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* This code was originally contributed by Matthew Byng-Maddick */
diff --git a/src/src/auths/dovecot.c b/src/src/auths/dovecot.c
index 2dcaa0e42..8c5b411de 100644
--- a/src/src/auths/dovecot.c
+++ b/src/src/auths/dovecot.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2004 Andrey Panin <pazke@donpac.ru>
- * Copyright (c) 2006-2016 The Exim Maintainers
+ * Copyright (c) 2006-2017 The Exim Maintainers
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
diff --git a/src/src/auths/get_data.c b/src/src/auths/get_data.c
index 3857e0738..9c793e3ab 100644
--- a/src/src/auths/get_data.c
+++ b/src/src/auths/get_data.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
diff --git a/src/src/auths/get_no64_data.c b/src/src/auths/get_no64_data.c
index 1bb611c1c..1006cf275 100644
--- a/src/src/auths/get_no64_data.c
+++ b/src/src/auths/get_no64_data.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2012 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
diff --git a/src/src/auths/gsasl_exim.c b/src/src/auths/gsasl_exim.c
index 48621a402..0ce9b9297 100644
--- a/src/src/auths/gsasl_exim.c
+++ b/src/src/auths/gsasl_exim.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2012 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Copyright (c) Twitter Inc 2012
diff --git a/src/src/auths/heimdal_gssapi.c b/src/src/auths/heimdal_gssapi.c
index 03a4bec79..b583a73fd 100644
--- a/src/src/auths/heimdal_gssapi.c
+++ b/src/src/auths/heimdal_gssapi.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Copyright (c) Twitter Inc 2012
diff --git a/src/src/auths/md5.c b/src/src/auths/md5.c
index 71b8c9952..d0037d92b 100644
--- a/src/src/auths/md5.c
+++ b/src/src/auths/md5.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2009 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#ifndef STAND_ALONE
diff --git a/src/src/auths/plaintext.c b/src/src/auths/plaintext.c
index 8bba05823..0bd67f686 100644
--- a/src/src/auths/plaintext.c
+++ b/src/src/auths/plaintext.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
diff --git a/src/src/auths/spa.c b/src/src/auths/spa.c
index f14ca5e54..9c0064ae4 100644
--- a/src/src/auths/spa.c
+++ b/src/src/auths/spa.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2009 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* This file, which provides support for Microsoft's Secure Password
diff --git a/src/src/auths/tls.c b/src/src/auths/tls.c
index bdcae3194..f29a22c82 100644
--- a/src/src/auths/tls.c
+++ b/src/src/auths/tls.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) Jeremy Harris 2016 */
+/* Copyright (c) Jeremy Harris 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* This file provides an Exim authenticator driver for
diff --git a/src/src/auths/xtextencode.c b/src/src/auths/xtextencode.c
index 4d189fc06..3fa57c4a7 100644
--- a/src/src/auths/xtextencode.c
+++ b/src/src/auths/xtextencode.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2009 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
diff --git a/src/src/base64.c b/src/src/base64.c
index 9dcbb74f0..f6f187f07 100644
--- a/src/src/base64.c
+++ b/src/src/base64.c
@@ -5,7 +5,7 @@
/* Copyright (c) Tom Kistner <tom@duncanthrax.net> 2004, 2015 */
/* License: GPL */
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/buildconfig.c b/src/src/buildconfig.c
index 4ed287414..22fde15ca 100644
--- a/src/src/buildconfig.c
+++ b/src/src/buildconfig.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
@@ -101,6 +101,7 @@ main(int argc, char **argv)
{
off_t test_off_t = 0;
time_t test_time_t = 0;
+ino_t test_ino_t;
#if ! (__STDC_VERSION__ >= 199901L)
size_t test_size_t = 0;
ssize_t test_ssize_t = 0;
@@ -153,13 +154,13 @@ This assumption is known to be OK for the common operating systems. */
fprintf(new, "#ifndef OFF_T_FMT\n");
if (sizeof(test_off_t) > sizeof(test_long_t))
{
- fprintf(new, "#define OFF_T_FMT \"%%lld\"\n");
- fprintf(new, "#define LONGLONG_T long long int\n");
+ fprintf(new, "# define OFF_T_FMT \"%%lld\"\n");
+ fprintf(new, "# define LONGLONG_T long long int\n");
}
else
{
- fprintf(new, "#define OFF_T_FMT \"%%ld\"\n");
- fprintf(new, "#define LONGLONG_T long int\n");
+ fprintf(new, "# define OFF_T_FMT \"%%ld\"\n");
+ fprintf(new, "# define LONGLONG_T long int\n");
}
fprintf(new, "#endif\n\n");
@@ -171,14 +172,23 @@ off_t. */
fprintf(new, "#ifndef TIME_T_FMT\n");
if (sizeof(test_time_t) > sizeof(test_long_t))
{
- fprintf(new, "#define TIME_T_FMT \"%%lld\"\n");
- fprintf(new, "#undef LONGLONG_T\n");
- fprintf(new, "#define LONGLONG_T long long int\n");
+ fprintf(new, "# define TIME_T_FMT \"%%lld\"\n");
+ fprintf(new, "# undef LONGLONG_T\n");
+ fprintf(new, "# define LONGLONG_T long long int\n");
}
else
- {
- fprintf(new, "#define TIME_T_FMT \"%%ld\"\n");
- }
+ fprintf(new, "# define TIME_T_FMT \"%%ld\"\n");
+fprintf(new, "#endif\n\n");
+
+fprintf(new, "#ifndef INO_T_FMT\n");
+if (sizeof(test_ino_t) > sizeof(test_long_t))
+ fprintf(new, "# define INO_T_FMT \"%%llu\"\n");
+else
+ fprintf(new, "# define INO_T_FMT \"%%lu\"\n");
+fprintf(new, "#endif\n\n");
+
+fprintf(new, "#ifndef PID_T_FMT\n");
+fprintf(new, "# define PID_T_FMT \"%%lu\"\n");
fprintf(new, "#endif\n\n");
/* And for sizeof() results, size_t, which should with C99 be just %zu, deal
diff --git a/src/src/config.h.defaults b/src/src/config.h.defaults
index dbfde8935..4750523dc 100644
--- a/src/src/config.h.defaults
+++ b/src/src/config.h.defaults
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* The default settings for Exim configuration variables. A #define without
diff --git a/src/src/dane-openssl.c b/src/src/dane-openssl.c
index 0a74f1f28..e48b0cb79 100644
--- a/src/src/dane-openssl.c
+++ b/src/src/dane-openssl.c
@@ -2,7 +2,7 @@
* Author: Viktor Dukhovni
* License: THIS CODE IS IN THE PUBLIC DOMAIN.
*
- * Copyright (c) The Exim Maintainers 2014 - 2016
+ * Copyright (c) The Exim Maintainers 2014 - 2017
*/
#include <stdio.h>
#include <string.h>
diff --git a/src/src/dbfn.c b/src/src/dbfn.c
index 5529fe93f..29d980802 100644
--- a/src/src/dbfn.c
+++ b/src/src/dbfn.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/dbstuff.h b/src/src/dbstuff.h
index aec549f48..adb362445 100644
--- a/src/src/dbstuff.h
+++ b/src/src/dbstuff.h
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2009 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* This header file contains macro definitions so that a variety of DBM
@@ -632,8 +632,12 @@ after reading data. */
# define EXIM_DBOPEN(name, dirname, flags, mode, dbpp) \
do { \
DEBUG(D_hints_lookup) \
- debug_printf("EXIM_DBOPEN: file <%s> dir <%s> flags 0x%x\n", \
- (name), (dirname), flags); \
+ debug_printf("EXIM_DBOPEN: file <%s> dir <%s> flags=%s\n", \
+ (name), (dirname), \
+ (flags) == O_RDONLY ? "O_RDONLY" \
+ : (flags) == O_RDWR ? "O_RDWR" \
+ : (flags) == (O_RDWR|O_CREAT) ? "O_RDWR|O_CREAT" \
+ : "??"); \
EXIM_DBOPEN__(name, dirname, flags, mode, dbpp); \
DEBUG(D_hints_lookup) debug_printf("returned from EXIM_DBOPEN: %p\n", *dbpp); \
} while(0)
diff --git a/src/src/dcc.c b/src/src/dcc.c
index a11e12df4..9a1657d26 100644
--- a/src/src/dcc.c
+++ b/src/src/dcc.c
@@ -7,7 +7,7 @@
* wbreyha@gmx.net
* See the file NOTICE for conditions of use and distribution.
*
- * Copyright (c) The Exim Maintainers 2015 - 2016
+ * Copyright (c) The Exim Maintainers 2015 - 2017
*/
/* This patch is based on code from Tom Kistners exiscan (ACL integration) and
diff --git a/src/src/debug.c b/src/src/debug.c
index 17a87d2d2..9e042f53f 100644
--- a/src/src/debug.c
+++ b/src/src/debug.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/deliver.c b/src/src/deliver.c
index 1241fa3cf..a7f561c9c 100644
--- a/src/src/deliver.c
+++ b/src/src/deliver.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* The main code for delivering a message. */
@@ -10,6 +10,7 @@
#include "exim.h"
#include "transports/smtp.h"
+#include <sys/uio.h>
#include <assert.h>
@@ -80,6 +81,52 @@ static uschar *used_return_path = NULL;
/*************************************************
+* read as much as requested *
+*************************************************/
+
+/* The syscall read(2) doesn't always returns as much as we want. For
+several reasons it might get less. (Not talking about signals, as syscalls
+are restartable). When reading from a network or pipe connection the sender
+might send in smaller chunks, with delays between these chunks. The read(2)
+may return such a chunk.
+
+The more the writer writes and the smaller the pipe between write and read is,
+the more we get the chance of reading leass than requested. (See bug 2130)
+
+This function read(2)s until we got all the data we *requested*.
+
+Note: This function may block. Use it only if you're sure about the
+amount of data you will get.
+
+Argument:
+ fd the file descriptor to read from
+ buffer pointer to a buffer of size len
+ len the requested(!) amount of bytes
+
+Returns: the amount of bytes read
+*/
+static ssize_t
+readn(int fd, void * buffer, size_t len)
+{
+ void * next = buffer;
+ void * end = buffer + len;
+
+ while (next < end)
+ {
+ ssize_t got = read(fd, next, end - next);
+
+ /* I'm not sure if there are signals that can interrupt us,
+ for now I assume the worst */
+ if (got == -1 && errno == EINTR) continue;
+ if (got <= 0) return next - buffer;
+ next += got;
+ }
+
+ return len;
+}
+
+
+/*************************************************
* Make a new address item *
*************************************************/
@@ -1424,7 +1471,7 @@ DEBUG(D_deliver) debug_printf("post-process %s (%d)\n", addr->address, result);
/* Set up driver kind and name for logging. Disable logging if the router or
transport has disabled it. */
-if (driver_type == DTYPE_TRANSPORT)
+if (driver_type == EXIM_DTYPE_TRANSPORT)
{
if (addr->transport)
{
@@ -1434,7 +1481,7 @@ if (driver_type == DTYPE_TRANSPORT)
}
else driver_kind = US"transporting";
}
-else if (driver_type == DTYPE_ROUTER)
+else if (driver_type == EXIM_DTYPE_ROUTER)
{
if (addr->router)
{
@@ -2628,7 +2675,7 @@ if (max_parallel > 0)
next = addr->next;
addr->message = US"concurrency limit reached for transport";
addr->basic_errno = ERRNO_TRETRY;
- post_process_one(addr, DEFER, LOG_MAIN, DTYPE_TRANSPORT, 0);
+ post_process_one(addr, DEFER, LOG_MAIN, EXIM_DTYPE_TRANSPORT, 0);
} while ((addr = next));
return TRUE;
}
@@ -2690,7 +2737,7 @@ while (addr_local)
addr->message = addr->router
? string_sprintf("No transport set by %s router", addr->router->name)
: string_sprintf("No transport set by system filter");
- post_process_one(addr, DEFER, logflags, DTYPE_TRANSPORT, 0);
+ post_process_one(addr, DEFER, logflags, EXIM_DTYPE_TRANSPORT, 0);
continue;
}
@@ -2825,7 +2872,7 @@ while (addr_local)
while (addr)
{
addr2 = addr->next;
- post_process_one(addr, rc, logflags, DTYPE_TRANSPORT, 0);
+ post_process_one(addr, rc, logflags, EXIM_DTYPE_TRANSPORT, 0);
addr = addr2;
}
continue; /* With next batch of addresses */
@@ -2927,7 +2974,7 @@ while (addr_local)
this->basic_errno = ERRNO_LRETRY;
addr2 = addr3 ? (addr3->next = addr2->next)
: (addr = addr2->next);
- post_process_one(this, DEFER, logflags, DTYPE_TRANSPORT, 0);
+ post_process_one(this, DEFER, logflags, EXIM_DTYPE_TRANSPORT, 0);
}
}
@@ -2950,7 +2997,7 @@ while (addr_local)
do
{
addr = addr->next;
- post_process_one(addr, DEFER, logflags, DTYPE_TRANSPORT, 0);
+ post_process_one(addr, DEFER, logflags, EXIM_DTYPE_TRANSPORT, 0);
} while ((addr = addr2));
}
continue; /* Loop for the next set of addresses. */
@@ -3107,7 +3154,7 @@ while (addr_local)
addr2->more_errno = deliver_time.tv_sec;
addr2->delivery_usec = deliver_time.tv_usec;
}
- post_process_one(addr2, result, logflags, DTYPE_TRANSPORT, logchar);
+ post_process_one(addr2, result, logflags, EXIM_DTYPE_TRANSPORT, logchar);
/* If a pipe delivery generated text to be sent back, the result may be
changed to FAIL, and we must copy this for subsequent addresses in the
@@ -3311,14 +3358,13 @@ while (!done)
If we get less, we can assume the subprocess do be done and do not expect any further
information from it. */
- got = readn(fd, pipeheader, required);
- if (got != required)
+ if ((got = readn(fd, pipeheader, required)) != required)
{
- msg = string_sprintf("got %d of %d bytes (pipeheader) "
- "from transport process %d for transport %s",
- got, PIPE_HEADER_SIZE, pid, addr->transport->driver_name);
- done = TRUE;
- break;
+ msg = string_sprintf("got " SSIZE_T_FMT " of %d bytes (pipeheader) "
+ "from transport process %d for transport %s",
+ got, PIPE_HEADER_SIZE, pid, addr->transport->driver_name);
+ done = TRUE;
+ break;
}
pipeheader[PIPE_HEADER_SIZE] = '\0';
@@ -3348,14 +3394,13 @@ while (!done)
/* Same as above, the transport process will write the bytes announced
in a timely manner, so we can just wait for the bytes, getting less than expected
is considered a problem of the subprocess, we do not expect anything else from it. */
- got = readn(fd, big_buffer, required);
- if (got != required)
+ if ((got = readn(fd, big_buffer, required)) != required)
{
- msg = string_sprintf("got only %d of %d bytes (pipedata) "
- "from transport process %d for transport %s",
- got, required, pid, addr->transport->driver_name);
- done = TRUE;
- break;
+ msg = string_sprintf("got only " SSIZE_T_FMT " of " SIZE_T_FMT
+ " bytes (pipedata) from transport process %d for transport %s",
+ got, required, pid, addr->transport->driver_name);
+ done = TRUE;
+ break;
}
/* Handle each possible type of item, assuming the complete item is
@@ -3757,7 +3802,7 @@ while (addr)
addr->transport_return = DEFER;
}
(void)post_process_one(addr, addr->transport_return, logflags,
- DTYPE_TRANSPORT, addr->special_action);
+ EXIM_DTYPE_TRANSPORT, addr->special_action);
}
/* Next address */
@@ -6048,7 +6093,7 @@ else if (system_filter && process_recipients != RECIP_FAIL_TIMEOUT)
p = p->next;
if (!addr_last) addr_new = p; else addr_last->next = p;
badp->local_part = badp->address; /* Needed for log line */
- post_process_one(badp, DEFER, LOG_MAIN|LOG_PANIC, DTYPE_ROUTER, 0);
+ post_process_one(badp, DEFER, LOG_MAIN|LOG_PANIC, EXIM_DTYPE_ROUTER, 0);
continue;
}
} /* End of pfr handling */
@@ -6166,7 +6211,7 @@ if (process_recipients != RECIP_IGNORE)
case RECIP_FAIL_LOOP:
new->message = US"Too many \"Received\" headers - suspected mail loop";
- post_process_one(new, FAIL, LOG_MAIN, DTYPE_ROUTER, 0);
+ post_process_one(new, FAIL, LOG_MAIN, EXIM_DTYPE_ROUTER, 0);
break;
@@ -6299,7 +6344,7 @@ while (addr_new) /* Loop until all addresses dealt with */
addr->message =
US"filter autoreply generated syntactically invalid recipient";
addr->prop.ignore_error = TRUE;
- (void) post_process_one(addr, FAIL, LOG_MAIN, DTYPE_ROUTER, 0);
+ (void) post_process_one(addr, FAIL, LOG_MAIN, EXIM_DTYPE_ROUTER, 0);
continue; /* with the next new address */
}
@@ -6366,7 +6411,7 @@ while (addr_new) /* Loop until all addresses dealt with */
{
addr->basic_errno = ERRNO_FORBIDFILE;
addr->message = US"delivery to file forbidden";
- (void)post_process_one(addr, FAIL, LOG_MAIN, DTYPE_ROUTER, 0);
+ (void)post_process_one(addr, FAIL, LOG_MAIN, EXIM_DTYPE_ROUTER, 0);
continue; /* with the next new address */
}
}
@@ -6376,7 +6421,7 @@ while (addr_new) /* Loop until all addresses dealt with */
{
addr->basic_errno = ERRNO_FORBIDPIPE;
addr->message = US"delivery to pipe forbidden";
- (void)post_process_one(addr, FAIL, LOG_MAIN, DTYPE_ROUTER, 0);
+ (void)post_process_one(addr, FAIL, LOG_MAIN, EXIM_DTYPE_ROUTER, 0);
continue; /* with the next new address */
}
}
@@ -6384,7 +6429,7 @@ while (addr_new) /* Loop until all addresses dealt with */
{
addr->basic_errno = ERRNO_FORBIDREPLY;
addr->message = US"autoreply forbidden";
- (void)post_process_one(addr, FAIL, LOG_MAIN, DTYPE_ROUTER, 0);
+ (void)post_process_one(addr, FAIL, LOG_MAIN, EXIM_DTYPE_ROUTER, 0);
continue; /* with the next new address */
}
@@ -6395,7 +6440,7 @@ while (addr_new) /* Loop until all addresses dealt with */
if (addr->basic_errno == ERRNO_BADTRANSPORT)
{
- (void)post_process_one(addr, DEFER, LOG_MAIN, DTYPE_ROUTER, 0);
+ (void)post_process_one(addr, DEFER, LOG_MAIN, EXIM_DTYPE_ROUTER, 0);
continue;
}
@@ -6407,7 +6452,7 @@ while (addr_new) /* Loop until all addresses dealt with */
{
uschar *save = addr->transport->name;
addr->transport->name = US"**bypassed**";
- (void)post_process_one(addr, OK, LOG_MAIN, DTYPE_TRANSPORT, '=');
+ (void)post_process_one(addr, OK, LOG_MAIN, EXIM_DTYPE_TRANSPORT, '=');
addr->transport->name = save;
continue; /* with the next new address */
}
@@ -6430,7 +6475,7 @@ while (addr_new) /* Loop until all addresses dealt with */
{
addr->message = US"cannot check percent_hack_domains";
addr->basic_errno = ERRNO_LISTDEFER;
- (void)post_process_one(addr, DEFER, LOG_MAIN, DTYPE_NONE, 0);
+ (void)post_process_one(addr, DEFER, LOG_MAIN, EXIM_DTYPE_NONE, 0);
continue;
}
@@ -6454,7 +6499,7 @@ while (addr_new) /* Loop until all addresses dealt with */
addr->message = US"domain is held";
addr->basic_errno = ERRNO_HELD;
}
- (void)post_process_one(addr, DEFER, LOG_MAIN, DTYPE_NONE, 0);
+ (void)post_process_one(addr, DEFER, LOG_MAIN, EXIM_DTYPE_NONE, 0);
continue;
}
@@ -6563,7 +6608,7 @@ while (addr_new) /* Loop until all addresses dealt with */
{
addr->message = US"reusing SMTP connection skips previous routing defer";
addr->basic_errno = ERRNO_RRETRY;
- (void)post_process_one(addr, DEFER, LOG_MAIN, DTYPE_ROUTER, 0);
+ (void)post_process_one(addr, DEFER, LOG_MAIN, EXIM_DTYPE_ROUTER, 0);
}
/* If we are in a queue run, defer routing unless there is no retry data or
@@ -6616,7 +6661,7 @@ while (addr_new) /* Loop until all addresses dealt with */
{
addr->message = US"retry time not reached";
addr->basic_errno = ERRNO_RRETRY;
- (void)post_process_one(addr, DEFER, LOG_MAIN, DTYPE_ROUTER, 0);
+ (void)post_process_one(addr, DEFER, LOG_MAIN, EXIM_DTYPE_ROUTER, 0);
}
/* The domain is OK for routing. Remember if retry data exists so it
@@ -6658,7 +6703,7 @@ while (addr_new) /* Loop until all addresses dealt with */
{
addr->basic_errno = ERRNO_LISTDEFER;
addr->message = US"queue_domains lookup deferred";
- (void)post_process_one(addr, DEFER, LOG_MAIN, DTYPE_ROUTER, 0);
+ (void)post_process_one(addr, DEFER, LOG_MAIN, EXIM_DTYPE_ROUTER, 0);
}
else
{
@@ -6669,7 +6714,7 @@ while (addr_new) /* Loop until all addresses dealt with */
{
addr->basic_errno = ERRNO_QUEUE_DOMAIN;
addr->message = US"domain is in queue_domains";
- (void)post_process_one(addr, DEFER, LOG_MAIN, DTYPE_ROUTER, 0);
+ (void)post_process_one(addr, DEFER, LOG_MAIN, EXIM_DTYPE_ROUTER, 0);
}
}
@@ -6734,7 +6779,7 @@ while (addr_new) /* Loop until all addresses dealt with */
if (rc != OK)
{
- (void)post_process_one(addr, rc, LOG_MAIN, DTYPE_ROUTER, 0);
+ (void)post_process_one(addr, rc, LOG_MAIN, EXIM_DTYPE_ROUTER, 0);
continue; /* route next address */
}
@@ -7037,7 +7082,7 @@ if (queue_run_local)
addr->next = NULL;
addr->basic_errno = ERRNO_LOCAL_ONLY;
addr->message = US"remote deliveries suppressed";
- (void)post_process_one(addr, DEFER, LOG_MAIN, DTYPE_TRANSPORT, 0);
+ (void)post_process_one(addr, DEFER, LOG_MAIN, EXIM_DTYPE_TRANSPORT, 0);
}
/* Handle remote deliveries */
@@ -8388,6 +8433,13 @@ return final_yield;
void
deliver_init(void)
{
+#ifdef EXIM_TFO_PROBE
+tfo_probe();
+#else
+tcp_fastopen_ok = TRUE;
+#endif
+
+
if (!regex_PIPELINING) regex_PIPELINING =
regex_must_compile(US"\\n250[\\s\\-]PIPELINING(\\s|\\n|$)", FALSE, TRUE);
@@ -8499,14 +8551,10 @@ if (cutthrough.fd >= 0 && cutthrough.callout_hold_only)
goto fail;
else if (pid == 0) /* child: fork again to totally disconnect */
- {
- close(pfd[1]);
- if ((pid = fork()))
- _exit(pid ? EXIT_FAILURE : EXIT_SUCCESS);
- smtp_proxy_tls(big_buffer, big_buffer_size, pfd[0], 5*60);
- exim_exit(0);
- }
+ /* does not return */
+ smtp_proxy_tls(big_buffer, big_buffer_size, pfd, 5*60);
+ DEBUG(D_transport) debug_printf("proxy-proc inter-pid %d\n", pid);
close(pfd[0]);
waitpid(pid, NULL, 0);
(void) close(channel_fd); /* release the client socket */
diff --git a/src/src/dkim.c b/src/src/dkim.c
index 723267cbf..d31cae9c7 100644
--- a/src/src/dkim.c
+++ b/src/src/dkim.c
@@ -12,7 +12,20 @@
#ifndef DISABLE_DKIM
-#include "pdkim/pdkim.h"
+# include "pdkim/pdkim.h"
+
+# ifdef MACRO_PREDEF
+# include "macro_predef.h"
+
+void
+params_dkim(void)
+{
+builtin_macro_create_var(US"_DKIM_SIGN_HEADERS", US PDKIM_DEFAULT_SIGN_HEADERS);
+}
+# else /*!MACRO_PREDEF*/
+
+
+
int dkim_verify_oldpool;
pdkim_ctx *dkim_verify_ctx = NULL;
@@ -125,7 +138,7 @@ void
dkim_exim_verify_finish(void)
{
pdkim_signature * sig = NULL;
-int dkim_signers_size = 0, dkim_signers_ptr = 0, rc;
+int rc;
gstring * g = NULL;
const uschar * errstr;
@@ -172,7 +185,7 @@ for (sig = dkim_signatures; sig; sig = sig->next)
" c=", sig->canon_headers == PDKIM_CANON_SIMPLE ? "simple" : "relaxed",
"/", sig->canon_body == PDKIM_CANON_SIMPLE ? "simple" : "relaxed",
" a=", dkim_sig_to_a_tag(sig),
- string_sprintf(" b=%d",
+ string_sprintf(" b=" SIZE_T_FMT,
(int)sig->sighash.len > -1 ? sig->sighash.len * 8 : 0));
if ((s= sig->identity)) logmsg = string_append(logmsg, 2, " i=", s);
if (sig->created > 0) logmsg = string_cat(logmsg,
@@ -340,7 +353,7 @@ switch (what)
case DKIM_BODYLENGTH:
return dkim_cur_sig->bodylength >= 0
- ? string_sprintf(OFF_T_FMT, (LONGLONG_T) dkim_cur_sig->bodylength)
+ ? string_sprintf("%ld", dkim_cur_sig->bodylength)
: dkim_exim_expand_defaults(what);
case DKIM_CANON_BODY:
@@ -365,12 +378,12 @@ switch (what)
case DKIM_CREATED:
return dkim_cur_sig->created > 0
- ? string_sprintf("%llu", dkim_cur_sig->created)
+ ? string_sprintf("%lu", dkim_cur_sig->created)
: dkim_exim_expand_defaults(what);
case DKIM_EXPIRES:
return dkim_cur_sig->expires > 0
- ? string_sprintf("%llu", dkim_cur_sig->expires)
+ ? string_sprintf("%lu", dkim_cur_sig->expires)
: dkim_exim_expand_defaults(what);
case DKIM_HEADERNAMES:
@@ -661,4 +674,5 @@ expand_bad:
goto bad;
}
-#endif
+# endif /*!MACRO_PREDEF*/
+#endif /*!DISABLE_DKIM*/
diff --git a/src/src/dkim.h b/src/src/dkim.h
index 8b12e21ed..735a1162a 100644
--- a/src/src/dkim.h
+++ b/src/src/dkim.h
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge, 1995 - 2016 */
+/* Copyright (c) University of Cambridge, 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
void dkim_exim_init(void);
diff --git a/src/src/dkim_transport.c b/src/src/dkim_transport.c
index b61c41edc..f707595cb 100644
--- a/src/src/dkim_transport.c
+++ b/src/src/dkim_transport.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Transport shim for dkim signing */
@@ -37,9 +37,17 @@ return TRUE;
/* Send the file at in_fd down the output fd */
static BOOL
-dkt_send_file(int out_fd, int in_fd, off_t off, size_t size)
+dkt_send_file(int out_fd, int in_fd, off_t off
+#ifdef OS_SENDFILE
+ , size_t size
+#endif
+ )
{
+#ifdef OS_SENDFILE
DEBUG(D_transport) debug_printf("send file fd=%d size=%u\n", out_fd, (unsigned)(size - off));
+#else
+DEBUG(D_transport) debug_printf("send file fd=%d\n", out_fd);
+#endif
/*XXX should implement timeout, like transport_write_block_fd() ? */
@@ -297,7 +305,11 @@ if (options & topt_use_bdat)
if(dlen > 0 && !transport_write_block(tctx, dkim_signature->s, dlen, TRUE))
goto err;
-if (!dkt_send_file(tctx->u.fd, dkim_fd, 0, k_file_size))
+if (!dkt_send_file(tctx->u.fd, dkim_fd, 0
+#ifdef OS_SENDFILE
+ , k_file_size
+#endif
+ ))
{
save_errno = errno;
rc = FALSE;
diff --git a/src/src/dmarc.c b/src/src/dmarc.c
index 704b0c88d..6cb5b19fe 100644
--- a/src/src/dmarc.c
+++ b/src/src/dmarc.c
@@ -79,12 +79,12 @@ return eblock;
messages on the same SMTP connection (that come from the
same host with the same HELO string) */
-int dmarc_init()
+int
+dmarc_init()
{
int *netmask = NULL; /* Ignored */
int is_ipv6 = 0;
-char *tld_file = (dmarc_tld_file == NULL) ?
- DMARC_TLD_FILE : CS dmarc_tld_file;
+char *tld_file = dmarc_tld_file ? CS dmarc_tld_file : DMARC_TLD_FILE;
/* Set some sane defaults. Also clears previous results when
* multiple messages in one connection. */
@@ -505,11 +505,11 @@ if (!dmarc_history_file)
history_file_fd = log_create(dmarc_history_file);
if (history_file_fd < 0)
-{
+ {
log_write(0, LOG_MAIN|LOG_PANIC, "failure to create DMARC history file: %s",
dmarc_history_file);
return DMARC_HIST_FILE_ERR;
-}
+ }
/* Generate the contents of the history file */
history_buffer = string_sprintf(
@@ -575,31 +575,24 @@ else
return DMARC_HIST_OK;
}
+
uschar *
dmarc_exim_expand_query(int what)
{
if (dmarc_disable_verify || !dmarc_pctx)
return dmarc_exim_expand_defaults(what);
-switch(what)
- {
- case DMARC_VERIFY_STATUS:
- return(dmarc_status);
- default:
- return US"";
- }
+if (what == DMARC_VERIFY_STATUS)
+ return dmarc_status;
+return US"";
}
uschar *
dmarc_exim_expand_defaults(int what)
{
-switch(what)
- {
- case DMARC_VERIFY_STATUS:
- return dmarc_disable_verify ? US"off" : US"none";
- default:
- return US"";
- }
+if (what == DMARC_VERIFY_STATUS)
+ return dmarc_disable_verify ? US"off" : US"none";
+return US"";
}
uschar *
diff --git a/src/src/drtables.c b/src/src/drtables.c
index 10b4ae8e0..1d8155798 100644
--- a/src/src/drtables.c
+++ b/src/src/drtables.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/exigrep.src b/src/src/exigrep.src
index 1899267be..bdeffae82 100644
--- a/src/src/exigrep.src
+++ b/src/src/exigrep.src
@@ -7,7 +7,7 @@ BEGIN { pop @INC if $INC[-1] eq '.' };
use Pod::Usage;
use Getopt::Long;
-# Copyright (c) 2007-2015 University of Cambridge.
+# Copyright (c) 2007-2017 University of Cambridge.
# See the file NOTICE for conditions of use and distribution.
# Except when they appear in comments, the following placeholders in this
diff --git a/src/src/exim.c b/src/src/exim.c
index 7114b7529..7dd084534 100644
--- a/src/src/exim.c
+++ b/src/src/exim.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
@@ -658,12 +658,13 @@ Returns: does not return
*/
void
-exim_exit(int rc)
+exim_exit(int rc, const uschar * process)
{
search_tidyup();
DEBUG(D_any)
- debug_printf(">>>>>>>>>>>>>>>> Exim pid=%d terminating with rc=%d "
- ">>>>>>>>>>>>>>>>\n", (int)getpid(), rc);
+ debug_printf(">>>>>>>>>>>>>>>> Exim pid=%d %s%s%sterminating with rc=%d "
+ ">>>>>>>>>>>>>>>>\n", (int)getpid(),
+ process ? "(" : "", process, process ? ") " : "", rc);
exit(rc);
}
@@ -840,7 +841,8 @@ fprintf(f, "Support for:");
fprintf(f, " SOCKS");
#endif
#ifdef TCP_FASTOPEN
- fprintf(f, " TCP_Fast_Open");
+ deliver_init();
+ if (tcp_fastopen_ok) fprintf(f, " TCP_Fast_Open");
#endif
#ifdef EXPERIMENTAL_LMDB
fprintf(f, " Experimental_LMDB");
@@ -3194,10 +3196,10 @@ for (i = 1; i < argc; i++)
which sets the host protocol and host name */
if (*argrest == 0)
- {
- if (i+1 < argc) argrest = argv[++i]; else
+ if (i+1 < argc)
+ argrest = argv[++i];
+ else
{ badarg = TRUE; break; }
- }
if (*argrest != 0)
{
@@ -3211,9 +3213,7 @@ for (i = 1; i < argc; i++)
hn = Ustrchr(argrest, ':');
if (hn == NULL)
- {
received_protocol = argrest;
- }
else
{
int old_pool = store_pool;
@@ -3793,12 +3793,9 @@ NOTE: immediatly after opening the configuration file we change the working
directory to "/"! Later we change to $spool_directory. We do it there, because
during readconf_main() some expansion takes place already. */
-/* Store the initial cwd before we change directories */
-if ((initial_cwd = os_getcwd(NULL, 0)) == NULL)
- {
- perror("exim: can't get the current working directory");
- exit(EXIT_FAILURE);
- }
+/* Store the initial cwd before we change directories. Can be NULL if the
+dir has already been unlinked. */
+initial_cwd = os_getcwd(NULL, 0);
/* checking:
-be[m] expansion test -
@@ -3876,7 +3873,7 @@ else
}
/* At this point, we know if the user is privileged and some command-line
-options become possibly imperssible, depending upon the configuration file. */
+options become possibly impermissible, depending upon the configuration file. */
if (checking && commandline_checks_require_admin && !admin_user) {
fprintf(stderr, "exim: those command-line flags are set to require admin\n");
@@ -4482,7 +4479,7 @@ if (test_retry_arg >= 0)
if (test_retry_arg >= argc)
{
printf("-brt needs a domain or address argument\n");
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, US"main");
}
s1 = argv[test_retry_arg++];
s2 = NULL;
@@ -4588,7 +4585,7 @@ if (test_retry_arg >= 0)
printf("\n");
}
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"main");
}
/* Handle a request to list one or more configuration options */
@@ -4612,14 +4609,14 @@ if (list_options)
}
else readconf_print(argv[i], NULL, flag_n);
}
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"main");
}
if (list_config)
{
set_process_info("listing config");
readconf_print(US"config", NULL, flag_n);
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"main");
}
@@ -4648,7 +4645,7 @@ if (msg_action_arg > 0 && msg_action != MSG_LOAD)
if (prod_requires_admin && !admin_user)
{
fprintf(stderr, "exim: Permission denied\n");
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, US"main");
}
set_process_info("delivering specified messages");
if (deliver_give_up) forced_delivery = deliver_force_thaw = TRUE;
@@ -4667,11 +4664,11 @@ if (msg_action_arg > 0 && msg_action != MSG_LOAD)
{
fprintf(stderr, "failed to fork delivery process for %s: %s\n", argv[i],
strerror(errno));
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, US"main");
}
else wait(&status);
}
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"main");
}
@@ -4690,7 +4687,7 @@ if (queue_interval == 0 && !daemon_listen)
else
set_process_info("running the queue (single queue run)");
queue_run(start_queue_run_id, stop_queue_run_id, FALSE);
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"main");
}
@@ -4713,10 +4710,9 @@ for (i = 0;;)
/* If user name has not been set by -F, set it from the passwd entry
unless -f has been used to set the sender address by a trusted user. */
- if (originator_name == NULL)
+ if (!originator_name)
{
- if (sender_address == NULL ||
- (!trusted_caller && filter_test == FTEST_NONE))
+ if (!sender_address || (!trusted_caller && filter_test == FTEST_NONE))
{
uschar *name = US pw->pw_gecos;
uschar *amp = Ustrchr(name, '&');
@@ -4726,11 +4722,11 @@ for (i = 0;;)
replaced by a copy of the login name, and some even specify that
the first character should be upper cased, so that's what we do. */
- if (amp != NULL)
+ if (amp)
{
int loffset;
string_format(buffer, sizeof(buffer), "%.*s%n%s%s",
- amp - name, name, &loffset, originator_login, amp + 1);
+ (int)(amp - name), name, &loffset, originator_login, amp + 1);
buffer[loffset] = toupper(buffer[loffset]);
name = buffer;
}
@@ -4738,7 +4734,7 @@ for (i = 0;;)
/* If a pattern for matching the gecos field was supplied, apply
it and then expand the name string. */
- if (gecos_pattern != NULL && gecos_name != NULL)
+ if (gecos_pattern && gecos_name)
{
const pcre *re;
re = regex_must_compile(gecos_pattern, FALSE, TRUE); /* Use malloc */
@@ -4747,7 +4743,7 @@ for (i = 0;;)
{
uschar *new_name = expand_string(gecos_name);
expand_nmax = -1;
- if (new_name != NULL)
+ if (new_name)
{
DEBUG(D_receive) debug_printf("user name \"%s\" extracted from "
"gecos field \"%s\"\n", new_name, name);
@@ -4844,10 +4840,10 @@ if (test_rewrite_arg >= 0)
if (test_rewrite_arg >= argc)
{
printf("-brw needs an address argument\n");
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, US"main");
}
rewrite_test(argv[test_rewrite_arg]);
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"main");
}
/* A locally-supplied message is considered to be coming from a local user
@@ -4962,7 +4958,7 @@ if (verify_address_mode || address_test_mode)
}
route_tidyup();
- exim_exit(exit_value);
+ exim_exit(exit_value, US"main");
}
/* Handle expansion checking. Either expand items on the command line, or read
@@ -5064,7 +5060,7 @@ if (expansion_test)
deliver_datafile = -1;
}
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"main");
}
@@ -5158,7 +5154,7 @@ if (host_checking)
}
smtp_log_no_mail();
}
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"main");
}
@@ -5322,7 +5318,7 @@ if (smtp_input)
if (!smtp_start_session())
{
mac_smtp_fflush();
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"smtp_start toplevel");
}
}
@@ -5437,14 +5433,14 @@ while (more)
cancel_cutthrough_connection(TRUE, US"receive dropped");
if (more) goto moreloop;
smtp_log_no_mail(); /* Log no mail if configured */
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, US"receive toplevel");
}
}
else
{
cancel_cutthrough_connection(TRUE, US"message setup dropped");
smtp_log_no_mail(); /* Log no mail if configured */
- exim_exit((rc == 0)? EXIT_SUCCESS : EXIT_FAILURE);
+ exim_exit(rc ? EXIT_FAILURE : EXIT_SUCCESS, US"msg setup toplevel");
}
}
@@ -5495,14 +5491,12 @@ while (more)
if (error_handling == ERRORS_STDERR)
{
fprintf(stderr, "exim: too many recipients\n");
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, US"main");
}
else
- {
return
moan_to_sender(ERRMESS_TOOMANYRECIP, NULL, NULL, stdin, TRUE)?
errors_sender_rc : EXIT_FAILURE;
- }
#ifdef SUPPORT_I18N
{
@@ -5531,7 +5525,7 @@ while (more)
{
fprintf(stderr, "exim: bad recipient address \"%s\": %s\n",
string_printing(list[i]), errmess);
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, US"main");
}
else
{
@@ -5604,7 +5598,7 @@ while (more)
for real; when reading the headers of a message for filter testing,
it is TRUE if the headers were terminated by '.' and FALSE otherwise. */
- if (message_id[0] == 0) exim_exit(EXIT_FAILURE);
+ if (message_id[0] == 0) exim_exit(EXIT_FAILURE, US"main");
} /* Non-SMTP message reception */
/* If this is a filter testing run, there are headers in store, but
@@ -5649,7 +5643,7 @@ while (more)
if (chdir("/")) /* Get away from wherever the user is running this from */
{
DEBUG(D_receive) debug_printf("chdir(\"/\") failed\n");
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, US"main");
}
/* Now we run either a system filter test, or a user filter test, or both.
@@ -5658,20 +5652,16 @@ while (more)
explicitly. */
if ((filter_test & FTEST_SYSTEM) != 0)
- {
if (!filter_runtest(filter_sfd, filter_test_sfile, TRUE, more))
- exim_exit(EXIT_FAILURE);
- }
+ exim_exit(EXIT_FAILURE, US"main");
memcpy(filter_sn, filter_n, sizeof(filter_sn));
if ((filter_test & FTEST_USER) != 0)
- {
if (!filter_runtest(filter_ufd, filter_test_ufile, FALSE, more))
- exim_exit(EXIT_FAILURE);
- }
+ exim_exit(EXIT_FAILURE, US"main");
- exim_exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS, US"main");
}
/* Else act on the result of message reception. We should not get here unless
@@ -5797,7 +5787,7 @@ while (more)
log_write(0, LOG_MAIN|LOG_PANIC,
"process %d crashed with signal %d while delivering %s",
(int)pid, status & 0x00ff, message_id);
- if (mua_wrapper && (status & 0xffff) != 0) exim_exit(EXIT_FAILURE);
+ if (mua_wrapper && (status & 0xffff) != 0) exim_exit(EXIT_FAILURE, US"main");
}
}
}
@@ -5829,54 +5819,9 @@ moreloop:
store_reset(reset_point);
}
-exim_exit(EXIT_SUCCESS); /* Never returns */
+exim_exit(EXIT_SUCCESS, US"main"); /* Never returns */
return 0; /* To stop compiler warning */
}
-/*************************************************
-* read as much as requested *
-*************************************************/
-
-/* The syscall read(2) doesn't always returns as much as we want. For
-several reasons it might get less. (Not talking about signals, as syscalls
-are restartable). When reading from a network or pipe connection the sender
-might send in smaller chunks, with delays between these chunks. The read(2)
-may return such a chunk.
-
-The more the writer writes and the smaller the pipe between write and read is,
-the more we get the chance of reading leass than requested. (See bug 2130)
-
-This function read(2)s until we got all the data we *requested*.
-
-Note: This function may block. Use it only if you're sure about the
-amount of data you will get.
-
-Argument:
- fd the file descriptor to read from
- buffer pointer to a buffer of size len
- len the requested(!) amount of bytes
-
-Returns: the amount of bytes read
-*/
-ssize_t
-readn(int fd, void *buffer, size_t len)
-{
- void *next = buffer;
- void *end = buffer + len;
-
- while (next < end)
- {
- ssize_t got = read(fd, next, end - next);
-
- /* I'm not sure if there are signals that can interrupt us,
- for now I assume the worst */
- if (got == -1 && errno == EINTR) continue;
- if (got <= 0) return next - buffer;
- next += got;
- }
-
- return len;
-}
-
/* End of exim.c */
diff --git a/src/src/exim.h b/src/src/exim.h
index f8dd9a9ba..770fd6333 100644
--- a/src/src/exim.h
+++ b/src/src/exim.h
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
@@ -597,9 +597,11 @@ default to EDQUOT if it exists, otherwise ENOSPC. */
# undef DISABLE_DNSSEC
#endif
-/* Wrapper around read(2) to read all the data we requested (BLOCKING) */
-ssize_t
-readn(int fd, void *buffer, size_t len);
+/* Some platforms (FreeBSD, OpenBSD, Solaris) do not seem to define this */
+
+#ifndef POLLRDHUP
+# define POLLRDHUP (POLLIN | POLLHUP)
+#endif
#endif
/* End of exim.h */
diff --git a/src/src/exim_dbmbuild.c b/src/src/exim_dbmbuild.c
index 7431bbc03..2dcc40f3e 100644
--- a/src/src/exim_dbmbuild.c
+++ b/src/src/exim_dbmbuild.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/exim_dbutil.c b/src/src/exim_dbutil.c
index fb455bbd3..4f3c4fadb 100644
--- a/src/src/exim_dbutil.c
+++ b/src/src/exim_dbutil.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/eximstats.src b/src/src/eximstats.src
index 727ee44b9..80ac93372 100644
--- a/src/src/eximstats.src
+++ b/src/src/eximstats.src
@@ -1,6 +1,6 @@
#!PERL_COMMAND
-# Copyright (c) 2001-2016 University of Cambridge.
+# Copyright (c) 2001-2017 University of Cambridge.
# See the file NOTICE for conditions of use and distribution.
# Perl script to generate statistics from one or more Exim log files.
diff --git a/src/src/exipick.src b/src/src/exipick.src
index 4751f7657..a1aa79dc0 100644
--- a/src/src/exipick.src
+++ b/src/src/exipick.src
@@ -1,4 +1,7 @@
#!PERL_COMMAND
+# Copyright (c) 2017 University of Cambridge.
+# See the file NOTICE for conditions of use and distribution.
+
# This variables should be set by the building process
my $spool = 'SPOOL_DIRECTORY'; # may be overridden later
@@ -387,7 +390,7 @@ sub process_criteria {
} else {
$c[-1]{cmp} .= $G::negate ? " ? 0 : 1" : " ? 1 : 0";
}
- # support the each_* psuedo variables. Steal the criteria off of the
+ # support the each_* pseudo variables. Steal the criteria off of the
# queue for special processing later
if ($c[-1]{var} =~ /^each_(recipients(_(un)?del)?)$/) {
my $var = $1;
@@ -1594,7 +1597,7 @@ TRUE if, under normal circumstances, Exim will not try to deliver the message.
=item S + $each_recipients
-This is a psuedo variable which allows you to apply a test against each address in $recipients individually. Whereas '$recipients =~ /@aol.com/' will match if any recipient address contains aol.com, '$each_recipients =~ /@aol.com$/' will only be true if every recipient matches that pattern. Note that this obeys --and or --or being set. Using it with --or is very similar to just matching against $recipients, but with the added benefit of being able to use anchors at the beginning and end of each recipient address.
+This is a pseudo variable which allows you to apply a test against each address in $recipients individually. Whereas '$recipients =~ /@aol.com/' will match if any recipient address contains aol.com, '$each_recipients =~ /@aol.com$/' will only be true if every recipient matches that pattern. Note that this obeys --and or --or being set. Using it with --or is very similar to just matching against $recipients, but with the added benefit of being able to use anchors at the beginning and end of each recipient address.
=item S + $each_recipients_del
diff --git a/src/src/expand.c b/src/src/expand.c
index 9cbfbe883..782467ff7 100644
--- a/src/src/expand.c
+++ b/src/src/expand.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
@@ -1484,14 +1484,14 @@ while (*s != 0)
/* If value2 is unset, just compute one number */
if (value2 < 0)
- s = string_sprintf("%d", total % value1);
+ s = string_sprintf("%lu", total % value1);
/* Otherwise do a div/mod hash */
else
{
total = total % (value1 * value2);
- s = string_sprintf("%d/%d", total/value2, total % value2);
+ s = string_sprintf("%lu/%lu", total/value2, total % value2);
}
*len = Ustrlen(s);
@@ -2821,18 +2821,21 @@ switch(cond_type)
uschar *save_iterate_item = iterate_item;
int (*compare)(const uschar *, const uschar *);
- DEBUG(D_expand) debug_printf_indent("condition: %s\n", name);
+ DEBUG(D_expand) debug_printf_indent("condition: %s item: %s\n", name, sub[0]);
tempcond = FALSE;
compare = cond_type == ECOND_INLISTI
? strcmpic : (int (*)(const uschar *, const uschar *)) strcmp;
while ((iterate_item = string_nextinlist(&list, &sep, NULL, 0)))
+ {
+ DEBUG(D_expand) debug_printf_indent(" compare %s\n", iterate_item);
if (compare(sub[0], iterate_item) == 0)
{
tempcond = TRUE;
break;
}
+ }
iterate_item = save_iterate_item;
}
@@ -3927,18 +3930,20 @@ while (*s != 0)
{
int len;
int newsize = 0;
- gstring * g;
+ gstring * g = NULL;
s = read_name(name, sizeof(name), s, US"_");
/* If this is the first thing to be expanded, release the pre-allocated
buffer. */
- if (yield && yield->ptr == 0)
+ if (!yield)
+ g = store_get(sizeof(gstring));
+ else if (yield->ptr == 0)
{
if (resetok) store_reset(yield);
yield = NULL;
- g = store_get(sizeof(gstring));
+ g = store_get(sizeof(gstring)); /* alloc _before_ calling find_variable() */
}
/* Header */
@@ -3993,7 +3998,8 @@ while (*s != 0)
yield->ptr = len;
yield->s = value;
}
- else yield = string_catn(yield, value, len);
+ else
+ yield = string_catn(yield, value, len);
continue;
}
@@ -6766,7 +6772,14 @@ while (*s != 0)
int start, end, domain; /* Not really used */
while (isspace(*sub)) sub++;
- if (*sub == '>') { *outsep = *++sub; ++sub; }
+ if (*sub == '>')
+ if (*outsep = *++sub) ++sub;
+ else
+ {
+ expand_string_message = string_sprintf("output separator "
+ "missing in expanding ${addresses:%s}", --sub);
+ goto EXPAND_FAILED;
+ }
parse_allow_group = TRUE;
for (;;)
@@ -7142,8 +7155,8 @@ while (*s != 0)
if (error != NULL)
{
expand_string_message = string_sprintf("error in expression "
- "evaluation: %s (after processing \"%.*s\")", error, sub-save_sub,
- save_sub);
+ "evaluation: %s (after processing \"%.*s\")", error,
+ (int)(sub-save_sub), save_sub);
goto EXPAND_FAILED;
}
sprintf(CS var_buffer, PR_EXIM_ARITH, n);
@@ -7422,13 +7435,15 @@ while (*s != 0)
{
int len;
int newsize = 0;
- gstring * g;
+ gstring * g = NULL;
- if (yield && yield->ptr == 0)
+ if (!yield)
+ g = store_get(sizeof(gstring));
+ else if (yield->ptr == 0)
{
if (resetok) store_reset(yield);
yield = NULL;
- g = store_get(sizeof(gstring));
+ g = store_get(sizeof(gstring)); /* alloc _before_ calling find_variable() */
}
if (!(value = find_variable(name, FALSE, skipping, &newsize)))
{
diff --git a/src/src/filter.c b/src/src/filter.c
index 0b3ef8b2d..01571218c 100644
--- a/src/src/filter.c
+++ b/src/src/filter.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
@@ -2322,7 +2322,7 @@ while (commands != NULL)
{
*error_pointer = string_sprintf("Bad time value for \"once_repeat\" "
"in mail or vacation command: %s",
- commands->args[mailarg_index_once_repeat]);
+ commands->args[mailarg_index_once_repeat].u);
return FF_ERROR;
}
}
diff --git a/src/src/functions.h b/src/src/functions.h
index 3bea9d2c1..1fe561f56 100644
--- a/src/src/functions.h
+++ b/src/src/functions.h
@@ -181,7 +181,7 @@ extern uschar *event_raise(uschar *, const uschar *, uschar *);
extern void msg_event_raise(const uschar *, const address_item *);
#endif
extern const uschar * exim_errstr(int);
-extern void exim_exit(int);
+extern void exim_exit(int, const uschar *);
extern void exim_nullstd(void);
extern void exim_setugid(uid_t, gid_t, BOOL, uschar *);
extern void exim_wait_tick(struct timeval *, int);
@@ -412,7 +412,7 @@ extern void smtp_get_cache(void);
extern int smtp_handle_acl_fail(int, int, uschar *, uschar *);
extern void smtp_log_no_mail(void);
extern void smtp_message_code(uschar **, int *, uschar **, uschar **, BOOL);
-extern void smtp_proxy_tls(uschar *, size_t, int, int);
+extern void smtp_proxy_tls(uschar *, size_t, int *, int);
extern BOOL smtp_read_response(smtp_inblock *, uschar *, int, int, int);
extern void smtp_respond(uschar *, int, BOOL, uschar *);
extern void smtp_notquit_exit(uschar *, uschar *, uschar *, ...);
@@ -478,6 +478,9 @@ extern int strcmpic(const uschar *, const uschar *);
extern int strncmpic(const uschar *, const uschar *, int);
extern uschar *strstric(uschar *, uschar *, BOOL);
+#ifdef EXIM_TFO_PROBE
+extern void tfo_probe(void);
+#endif
extern void timesince(struct timeval * diff, struct timeval * then);
extern void tls_modify_variables(tls_support *);
extern uschar *tod_stamp(int);
diff --git a/src/src/hash.c b/src/src/hash.c
index 19ab1efd0..ee4379648 100644
--- a/src/src/hash.c
+++ b/src/src/hash.c
@@ -1,8 +1,8 @@
/*
* Exim - an Internet mail transport agent
*
- * Copyright (C) 2016 Exim maintainers
- * Copyright (c) University of Cambridge 1995 - 2016
+ * Copyright (C) 2017 Exim maintainers
+ * Copyright (c) University of Cambridge 1995 - 2017
*
* Hash interface functions
*/
diff --git a/src/src/hash.h b/src/src/hash.h
index 337dc9910..79521f027 100644
--- a/src/src/hash.h
+++ b/src/src/hash.h
@@ -1,7 +1,7 @@
/*
* Exim - an Internet mail transport agent
*
- * Copyright (C) 2016 Exim maintainers
+ * Copyright (C) 2017 Exim maintainers
*
* Hash interface functions
*/
diff --git a/src/src/host.c b/src/src/host.c
index c02fc5532..05bde3fb2 100644
--- a/src/src/host.c
+++ b/src/src/host.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Functions for finding hosts, either by gethostbyname(), gethostbyaddr(), or
diff --git a/src/src/imap_utf7.c b/src/src/imap_utf7.c
index 323225c23..dfa50a9e1 100644
--- a/src/src/imap_utf7.c
+++ b/src/src/imap_utf7.c
@@ -1,3 +1,6 @@
+/* Copyright (c) University of Cambridge 2017 */
+/* See the file NOTICE for conditions of use and distribution. */
+
#include "exim.h"
#ifdef SUPPORT_I18N
diff --git a/src/src/ip.c b/src/src/ip.c
index e11aef985..e85dcb23e 100644
--- a/src/src/ip.c
+++ b/src/src/ip.c
@@ -161,6 +161,26 @@ return bind(sock, (struct sockaddr *)&sin, s_len);
/*************************************************
+*************************************************/
+
+#ifdef EXIM_TFO_PROBE
+void
+tfo_probe(void)
+{
+# ifdef TCP_FASTOPEN
+int sock, backlog = 5;
+
+if ( (sock = socket(SOCK_STREAM, AF_INET, 0)) < 0
+ && setsockopt(sock, IPPROTO_TCP, TCP_FASTOPEN, &backlog, sizeof(backlog))
+ )
+ tcp_fastopen_ok = TRUE;
+close(sock);
+# endif
+}
+#endif
+
+
+/*************************************************
* Connect socket to remote host *
*************************************************/
@@ -175,7 +195,7 @@ Arguments:
address the remote address, in text form
port the remote port
timeout a timeout (zero for indefinite timeout)
- fastopen non-null iff TCP_FASTOPEN can be used; may indicate early-data to
+ fastopen_blob non-null iff TCP_FASTOPEN can be used; may indicate early-data to
be sent in SYN segment
Returns: 0 on success; -1 on failure, with errno set
@@ -183,7 +203,7 @@ Returns: 0 on success; -1 on failure, with errno set
int
ip_connect(int sock, int af, const uschar *address, int port, int timeout,
- const blob * fastopen)
+ const blob * fastopen_blob)
{
struct sockaddr_in s_in4;
struct sockaddr *s_ptr;
@@ -232,16 +252,17 @@ before it gets our ACK of its SYN,ACK - the latter is useful for
the SMTP banner. Other (than SMTP) cases of TCP connections can
possibly use the data-on-syn, so support that too. */
-if (fastopen)
+if (fastopen_blob && tcp_fastopen_ok)
{
- if ((rc = sendto(sock, fastopen->data, fastopen->len,
+ if ((rc = sendto(sock, fastopen_blob->data, fastopen_blob->len,
MSG_FASTOPEN | MSG_DONTWAIT, s_ptr, s_len)) >= 0)
/* seen for with-data, experimental TFO option, with-cookie case */
/* seen for with-data, proper TFO opt, with-cookie case */
{
- DEBUG(D_transport|D_v) debug_printf("TFO mode connection attempt, %s data\n",
- fastopen->len > 0 ? "with" : "no");
- tcp_out_fastopen = fastopen->len > 0 ? 2 : 1;
+ DEBUG(D_transport|D_v)
+ debug_printf("non-TFO mode connection attempt to %s, %lu data\n",
+ address, (unsigned long)fastopen_blob->len);
+ tcp_out_fastopen = fastopen_blob->len > 0 ? 2 : 1;
}
else if (errno == EINPROGRESS) /* expected if we had no cookie for peer */
/* seen for no-data, proper TFO option, both cookie-request and with-cookie cases */
@@ -251,14 +272,14 @@ if (fastopen)
/* ? older Experimental TFO option behaviour ? */
{ /* queue unsent data */
DEBUG(D_transport|D_v) debug_printf("TFO mode sendto, %s data: EINPROGRESS\n",
- fastopen->len > 0 ? "with" : "no");
- if (!fastopen->data)
+ fastopen_blob->len > 0 ? "with" : "no");
+ if (!fastopen_blob->data)
{
tcp_out_fastopen = 1; /* we tried; unknown if useful yet */
rc = 0;
}
else
- rc = send(sock, fastopen->data, fastopen->len, 0);
+ rc = send(sock, fastopen_blob->data, fastopen_blob->len, 0);
}
else if(errno == EOPNOTSUPP)
{
@@ -271,9 +292,12 @@ else
#endif
{
legacy_connect:
+ DEBUG(D_transport|D_v) if (fastopen_blob)
+ debug_printf("non-TFO mode connection attempt to %s, %lu data\n",
+ address, (unsigned long)fastopen_blob->len);
if ((rc = connect(sock, s_ptr, s_len)) >= 0)
- if ( fastopen && fastopen->data && fastopen->len
- && send(sock, fastopen->data, fastopen->len, 0) < 0)
+ if ( fastopen_blob && fastopen_blob->data && fastopen_blob->len
+ && send(sock, fastopen_blob->data, fastopen_blob->len, 0) < 0)
rc = -1;
}
@@ -320,7 +344,7 @@ Arguments:
timeout a timeout
connhost if not NULL, host_item to be filled in with connection details
errstr pointer for allocated string on error
- fastopen with SOCK_STREAM, if non-null, request TCP Fast Open.
+ fastopen_blob with SOCK_STREAM, if non-null, request TCP Fast Open.
Additionally, optional early-data to send
Return:
@@ -328,7 +352,7 @@ Return:
*/
int
ip_connectedsocket(int type, const uschar * hostname, int portlo, int porthi,
- int timeout, host_item * connhost, uschar ** errstr, const blob * fastopen)
+ int timeout, host_item * connhost, uschar ** errstr, const blob * fastopen_blob)
{
int namelen, port;
host_item shost;
@@ -389,7 +413,7 @@ for (h = &shost; h; h = h->next)
}
for(port = portlo; port <= porthi; port++)
- if (ip_connect(fd, af, h->address, port, timeout, fastopen) == 0)
+ if (ip_connect(fd, af, h->address, port, timeout, fastopen_blob) == 0)
{
if (fd != fd6) close(fd6);
if (fd != fd4) close(fd4);
diff --git a/src/src/local_scan.h b/src/src/local_scan.h
index c03d87032..0aa6ef403 100644
--- a/src/src/local_scan.h
+++ b/src/src/local_scan.h
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* This file is the header that is the only Exim header to be included in the
diff --git a/src/src/log.c b/src/src/log.c
index fd72bb1ad..db82925e5 100644
--- a/src/src/log.c
+++ b/src/src/log.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Functions for writing log files. The code for maintaining datestamped
@@ -232,7 +232,7 @@ if (s1)
}
if (receive_call_bombout) receive_bomb_out(NULL, s2); /* does not return */
if (smtp_input) smtp_closedown(s2);
-exim_exit(EXIT_FAILURE);
+exim_exit(EXIT_FAILURE, NULL);
}
@@ -761,7 +761,7 @@ if (!log_buffer)
if (!(log_buffer = US malloc(LOG_BUFFER_SIZE)))
{
fprintf(stderr, "exim: failed to get store for log buffer\n");
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, NULL);
}
/* If we haven't already done so, inspect the setting of log_file_path to
@@ -958,7 +958,7 @@ if (!really_exim || log_testing_mode)
else
fprintf(log_stderr, "%s", CS log_buffer);
}
- if ((flags & LOG_PANIC_DIE) == LOG_PANIC_DIE) exim_exit(EXIT_FAILURE);
+ if ((flags & LOG_PANIC_DIE) == LOG_PANIC_DIE) exim_exit(EXIT_FAILURE, US"");
return;
}
diff --git a/src/src/lookups/dbmdb.c b/src/src/lookups/dbmdb.c
index 4b03c35f1..090be4f26 100644
--- a/src/src/lookups/dbmdb.c
+++ b/src/src/lookups/dbmdb.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
diff --git a/src/src/lookups/dnsdb.c b/src/src/lookups/dnsdb.c
index 9e95b9038..dfecb8166 100644
--- a/src/src/lookups/dnsdb.c
+++ b/src/src/lookups/dnsdb.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
diff --git a/src/src/lookups/ibase.c b/src/src/lookups/ibase.c
index 58bced201..acf9787a1 100644
--- a/src/src/lookups/ibase.c
+++ b/src/src/lookups/ibase.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* The code in this module was contributed by Ard Biesheuvel. */
diff --git a/src/src/lookups/ldap.c b/src/src/lookups/ldap.c
index 8d6ac2674..235af0f93 100644
--- a/src/src/lookups/ldap.c
+++ b/src/src/lookups/ldap.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Many thanks to Stuart Lynne for contributing the original code for this
diff --git a/src/src/lookups/lf_functions.h b/src/src/lookups/lf_functions.h
index 210aae4d5..b989f8459 100644
--- a/src/src/lookups/lf_functions.h
+++ b/src/src/lookups/lf_functions.h
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Header for the functions that are shared by the lookups */
diff --git a/src/src/lookups/lf_quote.c b/src/src/lookups/lf_quote.c
index 1541d0d16..83eac33b2 100644
--- a/src/src/lookups/lf_quote.c
+++ b/src/src/lookups/lf_quote.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2009 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/lookups/lf_sqlperform.c b/src/src/lookups/lf_sqlperform.c
index 6d4f7a798..5687fabe9 100644
--- a/src/src/lookups/lf_sqlperform.c
+++ b/src/src/lookups/lf_sqlperform.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
@@ -98,7 +98,7 @@ else
return DEFER;
}
- qserverlist = string_sprintf("%.*s", ss - s, s);
+ qserverlist = string_sprintf("%.*s", (int)(ss - s), s);
qsep = 0;
while ((qserver = string_nextinlist(&qserverlist, &qsep, qbuffer,
diff --git a/src/src/lookups/lmdb.c b/src/src/lookups/lmdb.c
index 55f273fd9..48ad489f9 100644
--- a/src/src/lookups/lmdb.c
+++ b/src/src/lookups/lmdb.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 2016 */
+/* Copyright (c) University of Cambridge 2016 - 2017*/
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
diff --git a/src/src/lookups/lsearch.c b/src/src/lookups/lsearch.c
index 745856d02..b236d8b72 100644
--- a/src/src/lookups/lsearch.c
+++ b/src/src/lookups/lsearch.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
diff --git a/src/src/lookups/mysql.c b/src/src/lookups/mysql.c
index 53789133e..ff1ef8325 100644
--- a/src/src/lookups/mysql.c
+++ b/src/src/lookups/mysql.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Thanks to Paul Kelly for contributing the original code for these
@@ -13,7 +13,53 @@ functions. */
#include "lf_functions.h"
#include <mysql.h> /* The system header */
-#include <mysql_version.h>
+
+/* We define symbols for *_VERSION_ID (numeric), *_VERSION_STR (char*)
+and *_BASE_STR (char*). It's a bit of guesswork. Especially for mariadb
+with versions before 10.2, as they do not define there there specific symbols.
+*/
+
+/* Newer (>= 10.2) MariaDB */
+#if defined MARIADB_VERSION_ID
+#define EXIM_MxSQL_VERSION_ID MARIADB_VERSION_ID
+
+/* MySQL defines MYSQL_VERSION_ID, and MariaDB does so */
+/* https://dev.mysql.com/doc/refman/5.7/en/c-api-server-client-versions.html */
+#elif defined LIBMYSQL_VERSION_ID
+#define EXIM_MxSQL_VERSION_ID LIBMYSQL_VERSION_ID
+#elif defined MYSQL_VERSION_ID
+#define EXIM_MxSQL_VERSION_ID MYSQL_VERSION_ID
+
+#else
+#define EXIM_MYSQL_VERSION_ID 0
+#endif
+
+/* Newer (>= 10.2) MariaDB */
+#ifdef MARIADB_CLIENT_VERSION_STR
+#define EXIM_MxSQL_VERSION_STR MARIADB_CLIENT_VERSION_STR
+
+/* Mysql uses MYSQL_SERVER_VERSION */
+#elif defined LIBMYSQL_VERSION
+#define EXIM_MxSQL_VERSION_STR LIBMYSQL_VERSION
+#elif defined MYSQL_SERVER_VERSION
+#define EXIM_MxSQL_VERSION_STR MYSQL_SERVER_VERSION
+
+#else
+#define EXIM_MxSQL_VERSION_STR "unknown"
+#endif
+
+#if defined MARIADB_BASE_VERSION
+#define EXIM_MxSQL_BASE_STR MARIADB_BASE_VERSION
+
+#elif defined MARIADB_PACKAGE_VERSION
+#define EXIM_MxSQL_BASE_STR "mariadb"
+
+#elif defined MYSQL_BASE_VERSION
+#define EXIM_MxSQL_BASE_STR MYSQL_BASE_VERSION
+
+#else
+#define EXIM_MxSQL_BASE_STR "n.A."
+#endif
/* Structure and anchor for caching connections. */
@@ -432,10 +478,10 @@ return quoted;
void
mysql_version_report(FILE *f)
{
-fprintf(f, "Library version: MySQL: Compile: %s [%s]\n"
- " Runtime: %s\n",
- MYSQL_SERVER_VERSION, MYSQL_COMPILATION_COMMENT,
- mysql_get_client_info());
+fprintf(f, "Library version: MySQL: Compile: %lu %s [%s]\n"
+ " Runtime: %lu %s\n",
+ (long)EXIM_MxSQL_VERSION_ID, EXIM_MxSQL_VERSION_STR, EXIM_MxSQL_BASE_STR,
+ mysql_get_client_version(), mysql_get_client_info());
#ifdef DYNLOOKUP
fprintf(f, " Exim version %s\n", EXIM_VERSION_STR);
#endif
diff --git a/src/src/lookups/nisplus.c b/src/src/lookups/nisplus.c
index 03c343103..e4184bbd6 100644
--- a/src/src/lookups/nisplus.c
+++ b/src/src/lookups/nisplus.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
diff --git a/src/src/lookups/pgsql.c b/src/src/lookups/pgsql.c
index ef8f0997d..0b771f59c 100644
--- a/src/src/lookups/pgsql.c
+++ b/src/src/lookups/pgsql.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Thanks to Petr Cech for contributing the original code for these
diff --git a/src/src/lookups/redis.c b/src/src/lookups/redis.c
index e8989ca3a..ad34d388c 100644
--- a/src/src/lookups/redis.c
+++ b/src/src/lookups/redis.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
diff --git a/src/src/lookups/sqlite.c b/src/src/lookups/sqlite.c
index 0df853736..ee8930d3c 100644
--- a/src/src/lookups/sqlite.c
+++ b/src/src/lookups/sqlite.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
diff --git a/src/src/macro_predef.c b/src/src/macro_predef.c
index 6b3157fbe..d13248ce4 100644
--- a/src/src/macro_predef.c
+++ b/src/src/macro_predef.c
@@ -21,7 +21,7 @@ uschar * syslog_facility_str;
/******************************************************************************/
void
-builtin_macro_create(const uschar * name)
+builtin_macro_create_var(const uschar * name, const uschar * val)
{
printf ("static macro_item p%d = { ", mp_index);
if (mp_index == 0)
@@ -29,12 +29,20 @@ if (mp_index == 0)
else
printf(".next=&p%d,", mp_index-1);
-printf(" .command_line=FALSE, .namelen=%d, .replen=1,"
- " .name=US\"%s\", .replacement=US\"y\" };\n",
- Ustrlen(name), CS name);
+printf(" .command_line=FALSE, .namelen=%d, .replen=%d,"
+ " .name=US\"%s\", .replacement=US\"%s\" };\n",
+ Ustrlen(name), Ustrlen(val), CS name, CS val);
mp_index++;
}
+
+void
+builtin_macro_create(const uschar * name)
+{
+builtin_macro_create_var(name, US"y");
+}
+
+
void
spf(uschar * buf, int len, const uschar * fmt, ...)
{
@@ -265,6 +273,14 @@ options_transports();
options_auths();
}
+static void
+params(void)
+{
+#ifndef DISABLE_DKIM
+params_dkim();
+#endif
+}
+
int
main(void)
@@ -272,6 +288,7 @@ main(void)
printf("#include \"exim.h\"\n");
features();
options();
+params();
printf("macro_item * macros = &p%d;\n", mp_index-1);
printf("macro_item * mlast = &p0;\n");
diff --git a/src/src/macro_predef.h b/src/src/macro_predef.h
index 1d3ba7f74..00d9537ca 100644
--- a/src/src/macro_predef.h
+++ b/src/src/macro_predef.h
@@ -9,10 +9,12 @@
extern void spf(uschar *, int, const uschar *, ...);
extern void builtin_macro_create(const uschar *);
+extern void builtin_macro_create_var(const uschar *, const uschar *);
extern void options_from_list(optionlist *, unsigned, const uschar *, uschar *);
extern void options_main(void);
extern void options_routers(void);
extern void options_transports(void);
extern void options_auths(void);
+extern void params_dkim(void);
diff --git a/src/src/macros.h b/src/src/macros.h
index eaa7f21ef..764c65b8d 100644
--- a/src/src/macros.h
+++ b/src/src/macros.h
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
@@ -107,8 +107,8 @@ don't make the file descriptors two-way. */
/* Debugging control */
-#define DEBUG(x) if ((debug_selector & (x)) != 0)
-#define HDEBUG(x) if (host_checking || (debug_selector & (x)) != 0)
+#define DEBUG(x) if (debug_selector & (x))
+#define HDEBUG(x) if (host_checking || (debug_selector & (x)))
#define PTR_CHK(ptr) \
do { \
@@ -224,9 +224,9 @@ enum { tod_log, tod_log_bare, tod_log_zone, tod_log_datestamp_daily,
/* For identifying types of driver */
enum {
- DTYPE_NONE,
- DTYPE_ROUTER,
- DTYPE_TRANSPORT
+ EXIM_DTYPE_NONE,
+ EXIM_DTYPE_ROUTER,
+ EXIM_DTYPE_TRANSPORT
};
/* Error numbers for generating error messages when reading a message on the
diff --git a/src/src/malware.c b/src/src/malware.c
index ccb7e6d20..9a98c9957 100644
--- a/src/src/malware.c
+++ b/src/src/malware.c
@@ -4,7 +4,7 @@
/* Copyright (c) Tom Kistner <tom@duncanthrax.net> 2003 - 2015
* License: GPL
- * Copyright (c) The Exim Maintainers 2016
+ * Copyright (c) The Exim Maintainers 2017
*/
/* Code for calling virus (malware) scanners. Called from acl.c. */
@@ -147,10 +147,10 @@ uses the returned in_addr to get a second connection to the same system.
*/
static inline int
m_tcpsocket(const uschar * hostname, unsigned int port,
- host_item * host, uschar ** errstr, const blob * fastopen)
+ host_item * host, uschar ** errstr, const blob * fastopen_blob)
{
return ip_connectedsocket(SOCK_STREAM, hostname, port, port, 5,
- host, errstr, fastopen);
+ host, errstr, fastopen_blob);
}
static int
diff --git a/src/src/match.c b/src/src/match.c
index 93777c6fe..c21711410 100644
--- a/src/src/match.c
+++ b/src/src/match.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Functions for matching strings */
diff --git a/src/src/mime.c b/src/src/mime.c
index 36737e9eb..45cec29a5 100644
--- a/src/src/mime.c
+++ b/src/src/mime.c
@@ -4,7 +4,7 @@
/* Copyright (c) Tom Kistner <tom@duncanthrax.net> 2004, 2015
* License: GPL
- * Copyright (c) The Exim Maintainers 2016
+ * Copyright (c) The Exim Maintainers 2017
*/
#include "exim.h"
diff --git a/src/src/moan.c b/src/src/moan.c
index 6d922a5a4..0228dcd4e 100644
--- a/src/src/moan.c
+++ b/src/src/moan.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Functions for sending messages to sender or to mailmaster. */
@@ -587,7 +587,7 @@ fprintf(stderr, "%d previous message%s successfully processed.\n",
fprintf(stderr, "The rest of the batch was abandoned.\n");
-exim_exit(yield);
+exim_exit(yield, US"batch");
}
diff --git a/src/src/mytypes.h b/src/src/mytypes.h
index a74705739..2d7134d2b 100644
--- a/src/src/mytypes.h
+++ b/src/src/mytypes.h
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/os.c b/src/src/os.c
index 6eadc38b1..592b76186 100644
--- a/src/src/os.c
+++ b/src/src/os.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#ifdef STAND_ALONE
diff --git a/src/src/parse.c b/src/src/parse.c
index 68a83b0e8..1b44146c5 100644
--- a/src/src/parse.c
+++ b/src/src/parse.c
@@ -745,7 +745,7 @@ if (*s == '<')
*errorptr = s[-1] == 0
? US"'>' missing at end of address"
: string_sprintf("malformed address: %.32s may not follow %.*s",
- s-1, s - US mailbox - 1, mailbox);
+ s-1, (int)(s - US mailbox - 1), mailbox);
goto PARSE_FAILED;
}
@@ -798,7 +798,7 @@ if (*s != 0)
else
{
*errorptr = string_sprintf("malformed address: %.32s may not follow %.*s",
- s, s - US mailbox, mailbox);
+ s, (int)(s - US mailbox), mailbox);
goto PARSE_FAILED;
}
}
diff --git a/src/src/pdkim/Makefile b/src/src/pdkim/Makefile
index 10631ceaa..c1d7db868 100644
--- a/src/src/pdkim/Makefile
+++ b/src/src/pdkim/Makefile
@@ -1,4 +1,5 @@
# Make file for building the pdkim library.
+# Copyright (c) The Exim Maintainers 2017
OBJ = pdkim.o signing.o
diff --git a/src/src/pdkim/crypt_ver.h b/src/src/pdkim/crypt_ver.h
index 439d99b3a..bf620366f 100644
--- a/src/src/pdkim/crypt_ver.h
+++ b/src/src/pdkim/crypt_ver.h
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) Jeremy Harris 2016 */
+/* Copyright (c) Jeremy Harris 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Signing and hashing routine selection for PDKIM */
diff --git a/src/src/pdkim/pdkim.c b/src/src/pdkim/pdkim.c
index 06d455d7d..1420b1a79 100644
--- a/src/src/pdkim/pdkim.c
+++ b/src/src/pdkim/pdkim.c
@@ -51,14 +51,6 @@
#define PDKIM_MAX_HEADERS 512
#define PDKIM_MAX_BODY_LINE_LEN 16384
#define PDKIM_DNS_TXT_MAX_NAMELEN 1024
-#define PDKIM_DEFAULT_SIGN_HEADERS "From:Sender:Reply-To:Subject:Date:"\
- "Message-ID:To:Cc:MIME-Version:Content-Type:"\
- "Content-Transfer-Encoding:Content-ID:"\
- "Content-Description:Resent-Date:Resent-From:"\
- "Resent-Sender:Resent-To:Resent-Cc:"\
- "Resent-Message-ID:In-Reply-To:References:"\
- "List-Id:List-Help:List-Unsubscribe:"\
- "List-Subscribe:List-Post:List-Owner:List-Archive"
/* -------------------------------------------------------------------------- */
struct pdkim_stringlist {
diff --git a/src/src/pdkim/pdkim.h b/src/src/pdkim/pdkim.h
index a34999ad8..067c574f2 100644
--- a/src/src/pdkim/pdkim.h
+++ b/src/src/pdkim/pdkim.h
@@ -26,6 +26,15 @@
#include "../blob.h"
#include "../hash.h"
+#define PDKIM_DEFAULT_SIGN_HEADERS "From:Sender:Reply-To:Subject:Date:"\
+ "Message-ID:To:Cc:MIME-Version:Content-Type:"\
+ "Content-Transfer-Encoding:Content-ID:"\
+ "Content-Description:Resent-Date:Resent-From:"\
+ "Resent-Sender:Resent-To:Resent-Cc:"\
+ "Resent-Message-ID:In-Reply-To:References:"\
+ "List-Id:List-Help:List-Unsubscribe:"\
+ "List-Subscribe:List-Post:List-Owner:List-Archive"
+
/* -------------------------------------------------------------------------- */
/* Length of the preallocated buffer for the "answer" from the dns/txt
callback function. This should match the maximum RDLENGTH from DNS. */
diff --git a/src/src/pdkim/pdkim_hash.h b/src/src/pdkim/pdkim_hash.h
index 008f277b3..8ea550290 100644
--- a/src/src/pdkim/pdkim_hash.h
+++ b/src/src/pdkim/pdkim_hash.h
@@ -1,7 +1,7 @@
/*
* PDKIM - a RFC4871 (DKIM) implementation
*
- * Copyright (C) 2016 Exim maintainers
+ * Copyright (C) 2017 Exim maintainers
*
* Hash interface functions
*/
diff --git a/src/src/pdkim/signing.c b/src/src/pdkim/signing.c
index 1396b194e..58edb4cdd 100644
--- a/src/src/pdkim/signing.c
+++ b/src/src/pdkim/signing.c
@@ -1,7 +1,7 @@
/*
* PDKIM - a RFC4871 (DKIM) implementation
*
- * Copyright (C) 2016 Exim maintainers
+ * Copyright (C) 2017 Exim maintainers
*
* signing/verification interface
*/
diff --git a/src/src/pdkim/signing.h b/src/src/pdkim/signing.h
index 61e241e5d..61a1a0ad4 100644
--- a/src/src/pdkim/signing.h
+++ b/src/src/pdkim/signing.h
@@ -1,7 +1,7 @@
/*
* PDKIM - a RFC4871 (DKIM) implementation
*
- * Copyright (C) 2016 Exim maintainers
+ * Copyright (C) 2017 Exim maintainers
*
* RSA signing/verification interface
*/
diff --git a/src/src/perl.c b/src/src/perl.c
index 6966d73b5..faaebf302 100644
--- a/src/src/perl.c
+++ b/src/src/perl.c
@@ -3,6 +3,7 @@
*************************************************/
/* Copyright (c) 1998 Malcolm Beattie */
+/* Copyright (C) 2017 Exim maintainers */
/* Modified by PH to get rid of the "na" usage, March 1999.
Modified further by PH for general tidying for Exim 4.
diff --git a/src/src/queue.c b/src/src/queue.c
index 8b0494b26..f94681197 100644
--- a/src/src/queue.c
+++ b/src/src/queue.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Functions that operate on the input queue. */
@@ -80,7 +80,11 @@ queue_filename *first = NULL;
queue_filename **append = &first;
while (a && b)
- if (Ustrcmp(a->text, b->text) < 0)
+ {
+ int d;
+ if ((d = Ustrncmp(a->text, b->text, 6)) == 0)
+ d = Ustrcmp(a->text + 14, b->text + 14);
+ if (d < 0)
{
*append = a;
append= &a->next;
@@ -92,6 +96,7 @@ while (a && b)
append= &b->next;
b = b->next;
}
+ }
*append = a ? a : b;
return first;
@@ -278,7 +283,7 @@ for (; i <= *subcount; i++)
if (root[j])
{
next = merge_queue_lists(next, root[j]);
- root[j] = (j == LOG2_MAXNODES - 1)? next : NULL;
+ root[j] = j == LOG2_MAXNODES - 1 ? next : NULL;
}
else
{
@@ -450,8 +455,8 @@ subsequent iterations.
When the first argument of queue_get_spool_list() is -1 (for queue_run_in_
order), it scans all directories and makes a single message list. */
-for (i = (queue_run_in_order? -1 : 0);
- i <= (queue_run_in_order? -1 : subcount);
+for (i = queue_run_in_order ? -1 : 0;
+ i <= (queue_run_in_order ? -1 : subcount);
i++)
{
queue_filename *f;
diff --git a/src/src/rda.c b/src/src/rda.c
index fb3edac17..80e210447 100644
--- a/src/src/rda.c
+++ b/src/src/rda.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* This module contains code for extracting addresses from a forwarding list
diff --git a/src/src/readconf.c b/src/src/readconf.c
index 1cbbd83ef..b34372c44 100644
--- a/src/src/readconf.c
+++ b/src/src/readconf.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Functions for reading the configuration file, and for displaying
@@ -3271,9 +3271,8 @@ if (trusted_config && Ustrcmp(filename, US"/dev/null"))
letter. If we see something starting with an upper case letter, it is taken as
a macro definition. */
-while ((s = get_config_line()) != NULL)
+while ((s = get_config_line()))
{
-
if (config_lineno == 1 && Ustrstr(s, "\xef\xbb\xbf") == s)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
"found unexpected BOM (Byte Order Mark)");
@@ -3441,7 +3440,7 @@ if (*log_file_path != 0)
openlog(). Default is LOG_MAIL set in globals.c. Allow the user to omit the
leading "log_". */
-if (syslog_facility_str != NULL)
+if (syslog_facility_str)
{
int i;
uschar *s = syslog_facility_str;
@@ -3451,27 +3450,22 @@ if (syslog_facility_str != NULL)
s += 4;
for (i = 0; i < syslog_list_size; i++)
- {
if (strcmpic(s, syslog_list[i].name) == 0)
{
syslog_facility = syslog_list[i].value;
break;
}
- }
if (i >= syslog_list_size)
- {
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"failed to interpret syslog_facility \"%s\"", syslog_facility_str);
- }
}
/* Expand pid_file_path */
if (*pid_file_path != 0)
{
- s = expand_string(pid_file_path);
- if (s == NULL)
+ if (!(s = expand_string(pid_file_path)))
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "failed to expand pid_file_path "
"\"%s\": %s", pid_file_path, expand_string_message);
pid_file_path = s;
@@ -3479,7 +3473,7 @@ if (*pid_file_path != 0)
/* Set default value of process_log_path */
-if (process_log_path == NULL || *process_log_path =='\0')
+if (!process_log_path || *process_log_path =='\0')
process_log_path = string_sprintf("%s/exim-process.info", spool_directory);
/* Compile the regex for matching a UUCP-style "From_" line in an incoming
@@ -3489,23 +3483,19 @@ regex_From = regex_must_compile(uucp_from_pattern, FALSE, TRUE);
/* Unpick the SMTP rate limiting options, if set */
-if (smtp_ratelimit_mail != NULL)
- {
+if (smtp_ratelimit_mail)
unpick_ratelimit(smtp_ratelimit_mail, &smtp_rlm_threshold,
&smtp_rlm_base, &smtp_rlm_factor, &smtp_rlm_limit);
- }
-if (smtp_ratelimit_rcpt != NULL)
- {
+if (smtp_ratelimit_rcpt)
unpick_ratelimit(smtp_ratelimit_rcpt, &smtp_rlr_threshold,
&smtp_rlr_base, &smtp_rlr_factor, &smtp_rlr_limit);
- }
/* The qualify domains default to the primary host name */
-if (qualify_domain_sender == NULL)
+if (!qualify_domain_sender)
qualify_domain_sender = primary_hostname;
-if (qualify_domain_recipient == NULL)
+if (!qualify_domain_recipient)
qualify_domain_recipient = qualify_domain_sender;
/* Setting system_filter_user in the configuration sets the gid as well if a
@@ -3514,7 +3504,7 @@ name is given, but a numerical value does not. */
if (system_filter_uid_set && !system_filter_gid_set)
{
struct passwd *pw = getpwuid(system_filter_uid);
- if (pw == NULL)
+ if (!pw)
log_write(0, LOG_MAIN|LOG_PANIC_DIE, "Failed to look up uid %ld",
(long int)system_filter_uid);
system_filter_gid = pw->pw_gid;
@@ -3524,14 +3514,14 @@ if (system_filter_uid_set && !system_filter_gid_set)
/* If the errors_reply_to field is set, check that it is syntactically valid
and ensure it contains a domain. */
-if (errors_reply_to != NULL)
+if (errors_reply_to)
{
uschar *errmess;
int start, end, domain;
uschar *recipient = parse_extract_address(errors_reply_to, &errmess,
&start, &end, &domain, FALSE);
- if (recipient == NULL)
+ if (!recipient)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"error in errors_reply_to (%s): %s", errors_reply_to, errmess);
@@ -3553,12 +3543,13 @@ if (smtp_accept_max == 0 &&
so that it can be computed from the host name, for example. We do this last
so as to ensure that everything else is set up before the expansion. */
-if (host_number_string != NULL)
+if (host_number_string)
{
long int n;
uschar *end;
uschar *s = expand_string(host_number_string);
- if (s == NULL)
+
+ if (!s)
log_write(0, LOG_MAIN|LOG_PANIC_DIE,
"failed to expand localhost_number \"%s\": %s",
host_number_string, expand_string_message);
@@ -3577,11 +3568,10 @@ if (host_number_string != NULL)
#ifdef SUPPORT_TLS
/* If tls_verify_hosts is set, tls_verify_certificates must also be set */
-if ((tls_verify_hosts != NULL || tls_try_verify_hosts != NULL) &&
- tls_verify_certificates == NULL)
+if ((tls_verify_hosts || tls_try_verify_hosts) && !tls_verify_certificates)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG,
"tls_%sverify_hosts is set, but tls_verify_certificates is not set",
- (tls_verify_hosts != NULL)? "" : "try_");
+ tls_verify_hosts ? "" : "try_");
/* This also checks that the library linkage is working and we can call
routines in it, so call even if tls_require_ciphers is unset */
diff --git a/src/src/receive.c b/src/src/receive.c
index 4fb0c26cb..31402925d 100644
--- a/src/src/receive.c
+++ b/src/src/receive.c
@@ -190,7 +190,7 @@ if (STATVFS(CS path, &statbuf) != 0)
log_write(0, LOG_MAIN|LOG_PANIC, "cannot accept message: failed to stat "
"%s directory %s: %s", name, path, strerror(errno));
smtp_closedown(US"spool or log directory problem");
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, NULL);
}
*inodeptr = (statbuf.F_FILES > 0)? statbuf.F_FAVAIL : -1;
@@ -343,7 +343,7 @@ if (!already_bombing_out)
/* Exit from the program (non-BSMTP cases) */
-exim_exit(EXIT_FAILURE);
+exim_exit(EXIT_FAILURE, NULL);
}
@@ -1142,7 +1142,7 @@ if (error_handling == ERRORS_SENDER)
else
fprintf(stderr, "exim: %s%s\n", text2, text1); /* Sic */
(void)fclose(f);
-exim_exit(error_rc);
+exim_exit(error_rc, US"");
}
@@ -2620,8 +2620,9 @@ letter and it is not used internally.
NOTE: If ever the format of message ids is changed, the regular expression for
checking that a string is in this format must be updated in a corresponding
way. It appears in the initializing code in exim.c. The macro MESSAGE_ID_LENGTH
-must also be changed to reflect the correct string length. Then, of course,
-other programs that rely on the message id format will need updating too. */
+must also be changed to reflect the correct string length. The queue-sort code
+needs to know the layout. Then, of course, other programs that rely on the
+message id format will need updating too. */
Ustrncpy(message_id, string_base62((long int)(message_id_tv.tv_sec)), 6);
message_id[6] = '-';
@@ -3323,7 +3324,7 @@ if (extract_recip && (bad_addresses != NULL || recipients_count == 0))
{
Uunlink(spool_name);
(void)fclose(data_file);
- exim_exit(error_rc);
+ exim_exit(error_rc, US"receiving");
}
}
diff --git a/src/src/regex.c b/src/src/regex.c
index 3560bef52..605ae5d25 100644
--- a/src/src/regex.c
+++ b/src/src/regex.c
@@ -4,7 +4,7 @@
/* Copyright (c) Tom Kistner <tom@duncanthrax.net> 2003-2015
* License: GPL
- * Copyright (c) The Exim Maintainers 2016
+ * Copyright (c) The Exim Maintainers 2017
*/
/* Code for matching regular expressions against headers and body.
diff --git a/src/src/retry.c b/src/src/retry.c
index 91c27104a..40cc2e98f 100644
--- a/src/src/retry.c
+++ b/src/src/retry.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Functions concerned with retrying unsuccessful deliveries. */
diff --git a/src/src/rewrite.c b/src/src/rewrite.c
index 830d2bb8d..fe6369f16 100644
--- a/src/src/rewrite.c
+++ b/src/src/rewrite.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Functions concerned with rewriting headers */
@@ -309,7 +309,7 @@ for (rule = rewrite_rules;
start = Ustrlen(pf1) + start + new - p1;
end = start + Ustrlen(newparsed);
- new = string_sprintf("%s%.*s%s", pf1, p2 - p1, p1, pf2);
+ new = string_sprintf("%s%.*s%s", pf1, (int)(p2 - p1), p1, pf2);
}
/* Now accept the whole thing */
diff --git a/src/src/rfc2047.c b/src/src/rfc2047.c
index cb4a661bf..6eb567521 100644
--- a/src/src/rfc2047.c
+++ b/src/src/rfc2047.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* This file contains a function for decoding message header lines that may
diff --git a/src/src/route.c b/src/src/route.c
index 1b9676f3f..c112169f7 100644
--- a/src/src/route.c
+++ b/src/src/route.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Functions concerned with routing, and the list of generic router options. */
diff --git a/src/src/routers/accept.c b/src/src/routers/accept.c
index b3a54e7cb..9d230bf20 100644
--- a/src/src/routers/accept.c
+++ b/src/src/routers/accept.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/routers/dnslookup.c b/src/src/routers/dnslookup.c
index 9e230b1be..5017efbee 100644
--- a/src/src/routers/dnslookup.c
+++ b/src/src/routers/dnslookup.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
diff --git a/src/src/routers/ipliteral.c b/src/src/routers/ipliteral.c
index 5cd6da52a..bc16b1b98 100644
--- a/src/src/routers/ipliteral.c
+++ b/src/src/routers/ipliteral.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/routers/iplookup.c b/src/src/routers/iplookup.c
index 3592809ea..34edf439d 100644
--- a/src/src/routers/iplookup.c
+++ b/src/src/routers/iplookup.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/routers/manualroute.c b/src/src/routers/manualroute.c
index a695a9b6a..105fec0fe 100644
--- a/src/src/routers/manualroute.c
+++ b/src/src/routers/manualroute.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/routers/queryprogram.c b/src/src/routers/queryprogram.c
index abba024db..c7886923c 100644
--- a/src/src/routers/queryprogram.c
+++ b/src/src/routers/queryprogram.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
diff --git a/src/src/routers/redirect.c b/src/src/routers/redirect.c
index 5b6a08818..c823f0234 100644
--- a/src/src/routers/redirect.c
+++ b/src/src/routers/redirect.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/routers/rf_change_domain.c b/src/src/routers/rf_change_domain.c
index 219e283cc..afd86f643 100644
--- a/src/src/routers/rf_change_domain.c
+++ b/src/src/routers/rf_change_domain.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
@@ -37,8 +37,8 @@ rf_change_domain(address_item *addr, const uschar *domain, BOOL rewrite,
{
address_item *parent = store_get(sizeof(address_item));
uschar *at = Ustrrchr(addr->address, '@');
-uschar *address = string_sprintf("%.*s@%s", at - addr->address, addr->address,
- domain);
+uschar *address = string_sprintf("%.*s@%s",
+ (int)(at - addr->address), addr->address, domain);
DEBUG(D_route) debug_printf("domain changed to %s\n", domain);
diff --git a/src/src/routers/rf_get_errors_address.c b/src/src/routers/rf_get_errors_address.c
index d81f0e907..46562a704 100644
--- a/src/src/routers/rf_get_errors_address.c
+++ b/src/src/routers/rf_get_errors_address.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
diff --git a/src/src/routers/rf_get_munge_headers.c b/src/src/routers/rf_get_munge_headers.c
index bf8dc4a5d..5cd046ffb 100644
--- a/src/src/routers/rf_get_munge_headers.c
+++ b/src/src/routers/rf_get_munge_headers.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
diff --git a/src/src/routers/rf_queue_add.c b/src/src/routers/rf_queue_add.c
index 1eb109c89..fa25aa598 100644
--- a/src/src/routers/rf_queue_add.c
+++ b/src/src/routers/rf_queue_add.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
diff --git a/src/src/sieve.c b/src/src/sieve.c
index 3bb10785b..5d6b611c3 100644
--- a/src/src/sieve.c
+++ b/src/src/sieve.c
@@ -3,7 +3,7 @@
*************************************************/
/* Copyright (c) Michael Haardt 2003 - 2015
- * Copyright (c) The Exim Maintainers 2016
+ * Copyright (c) The Exim Maintainers 2017
* See the file NOTICE for conditions of use and distribution.
*/
diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c
index 8e7e431cd..1fdb705a5 100644
--- a/src/src/smtp_in.c
+++ b/src/src/smtp_in.c
@@ -565,11 +565,12 @@ for(;;)
incomplete_transaction_log(US"sync failure");
log_write(0, LOG_MAIN|LOG_REJECT, "SMTP protocol synchronization error "
"(next input sent too soon: pipelining was not advertised): "
- "rejected \"%s\" %s next input=\"%s\"",
+ "rejected \"%s\" %s next input=\"%s\"%s",
smtp_cmd_buffer, host_and_ident(TRUE),
- string_printing(string_copyn(smtp_inptr, n)));
- (void) synprot_error(L_smtp_protocol_error, 554, NULL,
- US"SMTP synchronization error");
+ string_printing(string_copyn(smtp_inptr, n)),
+ smtp_inend - smtp_inptr > n ? "..." : "");
+ (void) synprot_error(L_smtp_protocol_error, 554, NULL,
+ US"SMTP synchronization error");
goto repeat_until_rset;
}
@@ -680,8 +681,11 @@ return buf;
void
bdat_flush_data(void)
{
-unsigned n = chunking_data_left;
-(void) bdat_getbuf(&n);
+while (chunking_data_left)
+{
+ unsigned n = chunking_data_left;
+ (void) bdat_getbuf(&n);
+}
receive_getc = lwr_receive_getc;
receive_getbuf = lwr_receive_getbuf;
@@ -841,7 +845,7 @@ if (!yield)
{
log_write(0, LOG_MAIN|LOG_PANIC, "string too large in smtp_printf()");
smtp_closedown(US"Unexpected error");
- exim_exit(EXIT_FAILURE);
+ exim_exit(EXIT_FAILURE, NULL);
}
/* If this is the first output for a (non-batch) RCPT command, see if all RCPTs
@@ -921,7 +925,7 @@ if (smtp_batched_input)
moan_smtp_batch(NULL, "421 SMTP command timeout"); /* Does not return */
smtp_notquit_exit(US"command-timeout", US"421",
US"%s: SMTP command timeout - closing connection", smtp_active_hostname);
-exim_exit(EXIT_FAILURE);
+exim_exit(EXIT_FAILURE, US"receiving");
}
@@ -945,7 +949,7 @@ if (smtp_batched_input)
moan_smtp_batch(NULL, "421 SIGTERM received"); /* Does not return */
smtp_notquit_exit(US"signal-exit", US"421",
US"%s: Service not available - closing connection", smtp_active_hostname);
-exim_exit(EXIT_FAILURE);
+exim_exit(EXIT_FAILURE, US"receiving");
}
diff --git a/src/src/smtp_out.c b/src/src/smtp_out.c
index 786f8b592..2373e493c 100644
--- a/src/src/smtp_out.c
+++ b/src/src/smtp_out.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* A number of functions for driving outgoing SMTP calls. */
@@ -212,7 +212,7 @@ int dscp_level;
int dscp_option;
int sock;
int save_errno = 0;
-const blob * fastopen = NULL;
+const blob * fastopen_blob = NULL;
#ifndef DISABLE_EVENT
@@ -265,12 +265,12 @@ else
{
#ifdef TCP_FASTOPEN
if (verify_check_given_host(&ob->hosts_try_fastopen, host) == OK)
- fastopen = early_data ? early_data : &tcp_fastopen_nodata;
+ fastopen_blob = early_data ? early_data : &tcp_fastopen_nodata;
#endif
- if (ip_connect(sock, host_af, host->address, port, timeout, fastopen) < 0)
+ if (ip_connect(sock, host_af, host->address, port, timeout, fastopen_blob) < 0)
save_errno = errno;
- else if (early_data && !fastopen && early_data->data && early_data->len)
+ else if (early_data && !fastopen_blob && early_data->data && early_data->len)
if (send(sock, early_data->data, early_data->len, 0) < 0)
save_errno = errno;
}
@@ -309,7 +309,7 @@ else
}
if (ob->keepalive) ip_keepalive(sock, host->address, TRUE);
#ifdef TCP_FASTOPEN
- if (fastopen) tfo_out_check(sock);
+ if (fastopen_blob) tfo_out_check(sock);
#endif
return sock;
}
diff --git a/src/src/spam.c b/src/src/spam.c
index 6ca6678f8..6b03a848f 100644
--- a/src/src/spam.c
+++ b/src/src/spam.c
@@ -4,7 +4,7 @@
/* Copyright (c) Tom Kistner <tom@duncanthrax.net> 2003 - 2015
* License: GPL
- * Copyright (c) The Exim Maintainers 2016
+ * Copyright (c) The Exim Maintainers 2017
*/
/* Code for calling spamassassin's spamd. Called from acl.c. */
diff --git a/src/src/spf.c b/src/src/spf.c
index 2741c7baf..c4c5ef761 100644
--- a/src/src/spf.c
+++ b/src/src/spf.c
@@ -5,7 +5,7 @@
/* Experimental SPF support.
Copyright (c) Tom Kistner <tom@duncanthrax.net> 2004 - 2014
License: GPL
- Copyright (c) The Exim Maintainers 2016
+ Copyright (c) The Exim Maintainers 2017
*/
/* Code for calling spf checks via libspf-alt. Called from acl.c. */
diff --git a/src/src/spool_in.c b/src/src/spool_in.c
index a5b14959f..2a99c63dd 100644
--- a/src/src/spool_in.c
+++ b/src/src/spool_in.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Functions for reading spool files. When compiling for a utility (eximon),
@@ -459,8 +459,8 @@ for (;;)
tree_node *node;
endptr = Ustrchr(big_buffer + 6, ' ');
if (endptr == NULL) goto SPOOL_FORMAT_ERROR;
- name = string_sprintf("%c%.*s", big_buffer[4], endptr - big_buffer - 6,
- big_buffer + 6);
+ name = string_sprintf("%c%.*s", big_buffer[4],
+ (int)(endptr - big_buffer - 6), big_buffer + 6);
if (sscanf(CS endptr, " %d", &count) != 1) goto SPOOL_FORMAT_ERROR;
node = acl_var_create(name);
node->data.ptr = store_get(count + 1);
diff --git a/src/src/spool_mbox.c b/src/src/spool_mbox.c
index 432634094..16b0a332c 100644
--- a/src/src/spool_mbox.c
+++ b/src/src/spool_mbox.c
@@ -4,7 +4,7 @@
/* Copyright (c) Tom Kistner <tom@duncanthrax.net> 2003 - 2015
* License: GPL
- * Copyright (c) The Exim Maintainers 2016
+ * Copyright (c) The Exim Maintainers 2017
*/
/* Code for setting up a MBOX style spool file inside a /scan/<msgid>
diff --git a/src/src/spool_out.c b/src/src/spool_out.c
index 449662253..d48841367 100644
--- a/src/src/spool_out.c
+++ b/src/src/spool_out.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Functions for writing spool files, and moving them about. */
diff --git a/src/src/std-crypto.c b/src/src/std-crypto.c
index d41e2a195..e315e993a 100644
--- a/src/src/std-crypto.c
+++ b/src/src/std-crypto.c
@@ -3,6 +3,7 @@
*************************************************/
/* Copyright (c) Phil Pennock 2012, 2016
+ * Copyright (c) The Exim Maintainers 2017
* But almost everything here is fixed published constants from RFCs, so also:
* Copyright (C) The Internet Society (2003)
* Copyright (C) The IETF Trust (2008)
diff --git a/src/src/store.c b/src/src/store.c
index 12db584ce..c7cf33c9a 100644
--- a/src/src/store.c
+++ b/src/src/store.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Exim gets and frees all its store through these functions. In the original
diff --git a/src/src/string.c b/src/src/string.c
index 6b7d9a067..2e919e6d9 100644
--- a/src/src/string.c
+++ b/src/src/string.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Miscellaneous string-handling functions. Some are not required for
@@ -1372,10 +1372,20 @@ while (*fp != 0)
break;
case 'p':
- if (p >= last - 24) { yield = FALSE; goto END_FORMAT; }
- strncpy(newformat, item_start, fp - item_start);
- newformat[fp - item_start] = 0;
- p += sprintf(CS p, newformat, va_arg(ap, void *));
+ {
+ void * ptr;
+ if (p >= last - 24) { yield = FALSE; goto END_FORMAT; }
+ /* sprintf() saying "(nil)" for a null pointer seems unreliable.
+ Handle it explicitly. */
+ if ((ptr = va_arg(ap, void *)))
+ {
+ strncpy(newformat, item_start, fp - item_start);
+ newformat[fp - item_start] = 0;
+ p += sprintf(CS p, newformat, ptr);
+ }
+ else
+ p += sprintf(CS p, "(nil)");
+ }
break;
/* %f format is inherently insecure if the numbers that it may be
diff --git a/src/src/structs.h b/src/src/structs.h
index 22c141c0d..6adb30023 100644
--- a/src/src/structs.h
+++ b/src/src/structs.h
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/tls-gnu.c b/src/src/tls-gnu.c
index d54c560f7..43094f30d 100644
--- a/src/src/tls-gnu.c
+++ b/src/src/tls-gnu.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Copyright (c) Phil Pennock 2012 */
diff --git a/src/src/tls-openssl.c b/src/src/tls-openssl.c
index 6f10cf5f7..58401e932 100644
--- a/src/src/tls-openssl.c
+++ b/src/src/tls-openssl.c
@@ -29,7 +29,7 @@ functions from the OpenSSL library. */
# include <openssl/ocsp.h>
#endif
#ifdef EXPERIMENTAL_DANE
-# include <danessl.h>
+# include "danessl.h"
#endif
diff --git a/src/src/tls.c b/src/src/tls.c
index a24b939a4..bba6acf6b 100644
--- a/src/src/tls.c
+++ b/src/src/tls.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* This module provides TLS (aka SSL) support for Exim. The code for OpenSSL is
diff --git a/src/src/tlscert-gnu.c b/src/src/tlscert-gnu.c
index c9df5ea19..385fb8d42 100644
--- a/src/src/tlscert-gnu.c
+++ b/src/src/tlscert-gnu.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) Jeremy Harris 2014 - 2015 */
+/* Copyright (c) Jeremy Harris 2014 - 2017 */
/* This file provides TLS/SSL support for Exim using the GnuTLS library,
one of the available supported implementations. This file is #included into
diff --git a/src/src/tlscert-openssl.c b/src/src/tlscert-openssl.c
index bfd4dc112..3f0767926 100644
--- a/src/src/tlscert-openssl.c
+++ b/src/src/tlscert-openssl.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) Jeremy Harris 2014 - 2016 */
+/* Copyright (c) Jeremy Harris 2014 - 2017 */
/* This module provides TLS (aka SSL) support for Exim using the OpenSSL
library. It is #included into the tls.c file when that library is used.
@@ -149,7 +149,7 @@ else
time_t t = mktime(&tm); /* make the tm self-consistent */
if (mod && Ustrcmp(mod, "int") == 0) /* seconds since epoch */
- s = string_sprintf("%u", t);
+ s = string_sprintf(TIME_T_FMT, t);
else
{
@@ -300,7 +300,7 @@ return mod ? tls_field_from_dn(cp, mod) : cp;
uschar *
tls_cert_version(void * cert, uschar * mod)
{
-return string_sprintf("%d", X509_get_version((X509 *)cert));
+return string_sprintf("%ld", X509_get_version((X509 *)cert));
}
uschar *
diff --git a/src/src/tod.c b/src/src/tod.c
index 76b6d2da9..55933dc84 100644
--- a/src/src/tod.c
+++ b/src/src/tod.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2014 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* A function for returning the time of day in various formats */
diff --git a/src/src/transport.c b/src/src/transport.c
index 75af68f9b..47da45fdf 100644
--- a/src/src/transport.c
+++ b/src/src/transport.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* General functions concerned with transportation, and generic options for all
@@ -588,7 +588,7 @@ at = Ustrrchr(addr->address, '@');
plen = (addr->prefix == NULL)? 0 : Ustrlen(addr->prefix);
slen = Ustrlen(addr->suffix);
-return string_sprintf("%.*s@%s", (at - addr->address - plen - slen),
+return string_sprintf("%.*s@%s", (int)(at - addr->address - plen - slen),
addr->address + plen, at + 1);
}
diff --git a/src/src/transports/appendfile.c b/src/src/transports/appendfile.c
index 3b463c644..ece1da51d 100644
--- a/src/src/transports/appendfile.c
+++ b/src/src/transports/appendfile.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
@@ -306,11 +306,11 @@ for (i = 0; i < 5; i++)
uschar *rest;
uschar *s = expand_string(q);
- if (s == NULL)
+ if (!s)
{
*errmsg = string_sprintf("Expansion of \"%s\" in %s transport failed: "
"%s", q, tblock->name, expand_string_message);
- return search_find_defer? DEFER : FAIL;
+ return search_find_defer ? DEFER : FAIL;
}
d = Ustrtod(s, &rest);
@@ -324,7 +324,8 @@ for (i = 0; i < 5; i++)
else if (tolower(*rest) == 'g') { d *= 1024.0*1024.0*1024.0; rest++; }
else if (*rest == '%' && i == 2)
{
- if (ob->quota_value <= 0 && !ob->maildir_use_size_file) d = 0;
+ if (ob->quota_value <= 0 && !ob->maildir_use_size_file)
+ d = 0;
else if ((int)d < 0 || (int)d > 100)
{
*errmsg = string_sprintf("Invalid quota_warn_threshold percentage (%d)"
@@ -340,8 +341,8 @@ for (i = 0; i < 5; i++)
appended. Currently only "no_check", so we can be lazy parsing it */
if (i < 2 && Ustrstr(rest, "/no_check") == rest)
{
- no_check = 1;
- rest += sizeof("/no_check") - 1;
+ no_check = 1;
+ rest += sizeof("/no_check") - 1;
}
while (isspace(*rest)) rest++;
@@ -359,41 +360,44 @@ for (i = 0; i < 5; i++)
switch (i)
{
case 0:
- if (d >= 2.0*1024.0*1024.0*1024.0 && sizeof(off_t) <= 4) which = US"quota";
- ob->quota_value = (off_t)d;
- ob->quota_no_check = no_check;
- q = ob->quota_filecount;
- break;
+ if (d >= 2.0*1024.0*1024.0*1024.0 && sizeof(off_t) <= 4)
+ which = US"quota";
+ ob->quota_value = (off_t)d;
+ ob->quota_no_check = no_check;
+ q = ob->quota_filecount;
+ break;
case 1:
- if (d >= 2.0*1024.0*1024.0*1024.0) which = US"quota_filecount";
- ob->quota_filecount_value = (int)d;
- ob->quota_filecount_no_check = no_check;
- q = ob->quota_warn_threshold;
- break;
+ if (d >= 2.0*1024.0*1024.0*1024.0)
+ which = US"quota_filecount";
+ ob->quota_filecount_value = (int)d;
+ ob->quota_filecount_no_check = no_check;
+ q = ob->quota_warn_threshold;
+ break;
case 2:
if (d >= 2.0*1024.0*1024.0*1024.0 && sizeof(off_t) <= 4)
- which = US"quota_warn_threshold";
- ob->quota_warn_threshold_value = (off_t)d;
- q = ob->mailbox_size_string;
- default_value = -1.0;
- break;
+ which = US"quota_warn_threshold";
+ ob->quota_warn_threshold_value = (off_t)d;
+ q = ob->mailbox_size_string;
+ default_value = -1.0;
+ break;
case 3:
- if (d >= 2.0*1024.0*1024.0*1024.0 && sizeof(off_t) <= 4)
- which = US"mailbox_size";;
- ob->mailbox_size_value = (off_t)d;
- q = ob->mailbox_filecount_string;
- break;
+ if (d >= 2.0*1024.0*1024.0*1024.0 && sizeof(off_t) <= 4)
+ which = US"mailbox_size";;
+ ob->mailbox_size_value = (off_t)d;
+ q = ob->mailbox_filecount_string;
+ break;
case 4:
- if (d >= 2.0*1024.0*1024.0*1024.0) which = US"mailbox_filecount";
- ob->mailbox_filecount_value = (int)d;
- break;
+ if (d >= 2.0*1024.0*1024.0*1024.0)
+ which = US"mailbox_filecount";
+ ob->mailbox_filecount_value = (int)d;
+ break;
}
- if (which != NULL)
+ if (which)
{
*errmsg = string_sprintf("%s value %.10g is too large (overflow) in "
"%s transport", which, d, tblock->name);
@@ -575,12 +579,12 @@ else if (ob->dirname == NULL && !ob->maildir_format && !ob->mailstore_format)
driver options. Only one of body_only and headers_only can be set. */
ob->options |=
- (tblock->body_only? topt_no_headers : 0) |
- (tblock->headers_only? topt_no_body : 0) |
- (tblock->return_path_add? topt_add_return_path : 0) |
- (tblock->delivery_date_add? topt_add_delivery_date : 0) |
- (tblock->envelope_to_add? topt_add_envelope_to : 0) |
- ((ob->use_crlf || ob->mbx_format)? topt_use_crlf : 0);
+ (tblock->body_only ? topt_no_headers : 0) |
+ (tblock->headers_only ? topt_no_body : 0) |
+ (tblock->return_path_add ? topt_add_return_path : 0) |
+ (tblock->delivery_date_add ? topt_add_delivery_date : 0) |
+ (tblock->envelope_to_add ? topt_add_envelope_to : 0) |
+ ((ob->use_crlf || ob->mbx_format) ? topt_use_crlf : 0);
}
@@ -892,7 +896,7 @@ if (dofcntl)
#ifndef NO_FLOCK
if (doflock && (yield >= 0))
{
- int flocktype = (fcntltype == F_WRLCK)? LOCK_EX : LOCK_SH;
+ int flocktype = (fcntltype == F_WRLCK) ? LOCK_EX : LOCK_SH;
if (flocktime > 0)
{
alarm(flocktime);
@@ -1271,7 +1275,7 @@ BOOL wait_for_tick = FALSE;
uid_t uid = geteuid(); /* See note above */
gid_t gid = getegid();
int mbformat;
-int mode = (addr->mode > 0)? addr->mode : ob->mode;
+int mode = (addr->mode > 0) ? addr->mode : ob->mode;
off_t saved_size = -1;
off_t mailbox_size = ob->mailbox_size_value;
int mailbox_filecount = ob->mailbox_filecount_value;
@@ -1349,7 +1353,7 @@ if ((ob->maildir_format || ob->mailstore_format) && !isdirectory)
addr->transport_return = PANIC;
addr->message = string_sprintf("mail%s_format requires \"directory\" "
"to be specified for the %s transport",
- ob->maildir_format? "dir" : "store", tblock->name);
+ ob->maildir_format ? "dir" : "store", tblock->name);
return FALSE;
}
@@ -1389,10 +1393,10 @@ if (isdirectory)
{
mbformat =
#ifdef SUPPORT_MAILDIR
- (ob->maildir_format)? mbf_maildir :
+ (ob->maildir_format) ? mbf_maildir :
#endif
#ifdef SUPPORT_MAILSTORE
- (ob->mailstore_format)? mbf_mailstore :
+ (ob->mailstore_format) ? mbf_mailstore :
#endif
mbf_smail;
}
@@ -1400,7 +1404,7 @@ else
{
mbformat =
#ifdef SUPPORT_MBX
- (ob->mbx_format)? mbf_mbx :
+ (ob->mbx_format) ? mbf_mbx :
#endif
mbf_unix;
}
@@ -1413,22 +1417,22 @@ DEBUG(D_transport)
" %s=%s format=%s\n message_prefix=%s\n message_suffix=%s\n "
"maildir_use_size_file=%s\n",
mode, ob->notify_comsat, ob->quota_value,
- ob->quota_no_check? " (no_check)" : "",
- ob->quota_filecount_no_check? " (no_check_filecount)" : "",
+ ob->quota_no_check ? " (no_check)" : "",
+ ob->quota_filecount_no_check ? " (no_check_filecount)" : "",
ob->quota_warn_threshold_value,
- ob->quota_warn_threshold_is_percent? "%" : "",
- isdirectory? "directory" : "file",
+ ob->quota_warn_threshold_is_percent ? "%" : "",
+ isdirectory ? "directory" : "file",
path, mailbox_formats[mbformat],
- (ob->message_prefix == NULL)? US"null" : string_printing(ob->message_prefix),
- (ob->message_suffix == NULL)? US"null" : string_printing(ob->message_suffix),
- (ob->maildir_use_size_file)? "yes" : "no");
+ (ob->message_prefix == NULL) ? US"null" : string_printing(ob->message_prefix),
+ (ob->message_suffix == NULL) ? US"null" : string_printing(ob->message_suffix),
+ (ob->maildir_use_size_file) ? "yes" : "no");
if (!isdirectory) debug_printf(" locking by %s%s%s%s%s\n",
- ob->use_lockfile? "lockfile " : "",
- ob->use_mbx_lock? "mbx locking (" : "",
- ob->use_fcntl? "fcntl " : "",
- ob->use_flock? "flock" : "",
- ob->use_mbx_lock? ")" : "");
+ ob->use_lockfile ? "lockfile " : "",
+ ob->use_mbx_lock ? "mbx locking (" : "",
+ ob->use_fcntl ? "fcntl " : "",
+ ob->use_flock ? "flock" : "",
+ ob->use_mbx_lock ? ")" : "");
}
/* If the -N option is set, can't do any more. */
@@ -1740,7 +1744,7 @@ if (!isdirectory)
int sleep_before_retry = TRUE;
file_opened = FALSE;
- if((use_lstat? Ulstat(filename, &statbuf) : Ustat(filename, &statbuf)) != 0)
+ if((use_lstat ? Ulstat(filename, &statbuf) : Ustat(filename, &statbuf)) != 0)
{
/* Let's hope that failure to stat (other than non-existence) is a
rare event. */
@@ -1787,7 +1791,7 @@ if (!isdirectory)
get a shared lock. */
fd = Uopen(filename, O_RDWR | O_APPEND | O_CREAT |
- (use_lstat? O_EXCL : 0), mode);
+ (use_lstat ? O_EXCL : 0), mode);
if (fd < 0)
{
if (errno == EEXIST) continue;
@@ -1836,7 +1840,7 @@ if (!isdirectory)
addr->basic_errno = ERRNO_BADUGID;
addr->message = string_sprintf("mailbox %s%s has wrong uid "
"(%ld != %ld)", filename,
- islink? " (symlink)" : "",
+ islink ? " (symlink)" : "",
(long int)(statbuf.st_uid), (long int)uid);
goto RETURN;
}
@@ -1847,7 +1851,7 @@ if (!isdirectory)
{
addr->basic_errno = ERRNO_BADUGID;
addr->message = string_sprintf("mailbox %s%s has wrong gid (%d != %d)",
- filename, islink? " (symlink)" : "", statbuf.st_gid, gid);
+ filename, islink ? " (symlink)" : "", statbuf.st_gid, gid);
goto RETURN;
}
@@ -1858,7 +1862,7 @@ if (!isdirectory)
{
addr->basic_errno = ERRNO_NOTREGULAR;
addr->message = string_sprintf("mailbox %s%s has too many links (%d)",
- filename, islink? " (symlink)" : "", statbuf.st_nlink);
+ filename, islink ? " (symlink)" : "", statbuf.st_nlink);
goto RETURN;
}
@@ -1884,7 +1888,7 @@ if (!isdirectory)
{
addr->basic_errno = ERRNO_NOTREGULAR;
addr->message = string_sprintf("mailbox %s is not a regular file%s",
- filename, ob->allow_fifo? " or named pipe" : "");
+ filename, ob->allow_fifo ? " or named pipe" : "");
goto RETURN;
}
@@ -1933,7 +1937,7 @@ if (!isdirectory)
a FIFO is opened WRONLY + NDELAY so that it fails if there is no process
reading the pipe. */
- fd = Uopen(filename, isfifo? (O_WRONLY|O_NDELAY) : (O_RDWR|O_APPEND),
+ fd = Uopen(filename, isfifo ? (O_WRONLY|O_NDELAY) : (O_RDWR|O_APPEND),
mode);
if (fd < 0)
{
@@ -1980,7 +1984,7 @@ if (!isdirectory)
{
addr->basic_errno = ERRNO_INODECHANGED;
addr->message = string_sprintf("opened mailbox %s inode number changed "
- "from %d to %ld", filename, inode, statbuf.st_ino);
+ "from " INO_T_FMT " to " INO_T_FMT, filename, inode, statbuf.st_ino);
addr->special_action = SPECIAL_FREEZE;
goto RETURN;
}
@@ -1994,7 +1998,7 @@ if (!isdirectory)
addr->basic_errno = ERRNO_NOTREGULAR;
addr->message =
string_sprintf("opened mailbox %s is no longer a %s", filename,
- isfifo? "named pipe" : "regular file");
+ isfifo ? "named pipe" : "regular file");
addr->special_action = SPECIAL_FREEZE;
goto RETURN;
}
@@ -2432,7 +2436,7 @@ else
{
uschar *s = path + check_path_len;
while (*s == '/') s++;
- s = (*s == 0)? US "new" : string_sprintf("%s/new", s);
+ s = (*s == 0) ? US "new" : string_sprintf("%s/new", s);
if (pcre_exec(dir_regex, NULL, CS s, Ustrlen(s), 0, 0, NULL, 0) < 0)
{
disable_quota = TRUE;
@@ -2571,7 +2575,7 @@ else
uschar *basename;
(void)gettimeofday(&msg_tv, NULL);
- basename = string_sprintf(TIME_T_FMT ".H%luP%lu.%s",
+ basename = string_sprintf(TIME_T_FMT ".H%luP" PID_T_FMT ".%s",
msg_tv.tv_sec, msg_tv.tv_usec, getpid(), primary_hostname);
filename = dataname = string_sprintf("tmp/%s", basename);
@@ -2592,7 +2596,7 @@ else
if (i >= ob->maildir_retries)
{
addr->message = string_sprintf ("failed to open %s (%d tr%s)",
- filename, i, (i == 1)? "y" : "ies");
+ filename, i, (i == 1) ? "y" : "ies");
addr->basic_errno = errno;
if (errno == errno_quota || errno == ENOSPC)
addr->user_message = US"mailbox is full";
@@ -2801,12 +2805,12 @@ if (!disable_quota && ob->quota_value > 0)
debug_printf("Exim quota = " OFF_T_FMT " old size = " OFF_T_FMT
" this message = %d (%sincluded)\n",
ob->quota_value, mailbox_size, message_size,
- ob->quota_is_inclusive? "" : "not ");
+ ob->quota_is_inclusive ? "" : "not ");
debug_printf(" file count quota = %d count = %d\n",
ob->quota_filecount_value, mailbox_filecount);
}
- if (mailbox_size + (ob->quota_is_inclusive? message_size:0) > ob->quota_value)
+ if (mailbox_size + (ob->quota_is_inclusive ? message_size:0) > ob->quota_value)
{
if (!ob->quota_no_check)
@@ -2898,7 +2902,7 @@ if (yield == OK && ob->use_bsmtp)
transport_newlines++;
for (a = addr; a != NULL; a = a->next)
{
- address_item *b = testflag(a, af_pfr)? a->parent: a;
+ address_item *b = testflag(a, af_pfr) ? a->parent: a;
if (!transport_write_string(fd, "RCPT TO:<%s>%s\n",
transport_rcpt_address(b, tblock->rcpt_include_affixes), cr))
{ yield = DEFER; break; }
@@ -3078,7 +3082,7 @@ if (yield != OK)
}
else /* Want a repeatable time when in test harness */
{
- addr->more_errno = running_in_test_harness? 10 :
+ addr->more_errno = running_in_test_harness ? 10 :
(int)time(NULL) - statbuf.st_mtime;
}
DEBUG(D_transport)
@@ -3103,8 +3107,8 @@ if (yield != OK)
addr->user_message = US"mailbox is full";
DEBUG(D_transport) debug_printf("System quota exceeded for %s%s%s\n",
dataname,
- isdirectory? US"" : US": time since file read = ",
- isdirectory? US"" : readconf_printtime(addr->more_errno));
+ isdirectory ? US"" : US": time since file read = ",
+ isdirectory ? US"" : readconf_printtime(addr->more_errno));
}
/* Handle Exim's own quota-imposition */
@@ -3117,8 +3121,8 @@ if (yield != OK)
addr->user_message = US"mailbox is full";
DEBUG(D_transport) debug_printf("Exim%s quota exceeded for %s%s%s\n",
filecount_msg, dataname,
- isdirectory? US"" : US": time since file read = ",
- isdirectory? US"" : readconf_printtime(addr->more_errno));
+ isdirectory ? US"" : US": time since file read = ",
+ isdirectory ? US"" : readconf_printtime(addr->more_errno));
}
/* Handle a process failure while writing via a filter; the return
@@ -3129,7 +3133,7 @@ if (yield != OK)
yield = PANIC;
addr->message = string_sprintf("transport filter process failed (%d) "
"while writing to %s%s", addr->more_errno, dataname,
- (addr->more_errno == EX_EXECFAILED)? ": unable to execute command" : "");
+ (addr->more_errno == EX_EXECFAILED) ? ": unable to execute command" : "");
}
/* Handle failure to expand header changes */
@@ -3203,7 +3207,7 @@ else
{
addr->basic_errno = errno;
addr->message = string_sprintf("close() error for %s",
- (ob->mailstore_format)? dataname : filename);
+ (ob->mailstore_format) ? dataname : filename);
yield = DEFER;
}
diff --git a/src/src/transports/appendfile.h b/src/src/transports/appendfile.h
index 70330857d..e2c919796 100644
--- a/src/src/transports/appendfile.h
+++ b/src/src/transports/appendfile.h
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2009 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Private structure for the private options. */
diff --git a/src/src/transports/autoreply.c b/src/src/transports/autoreply.c
index 9f6e2acaf..bf31951fa 100644
--- a/src/src/transports/autoreply.c
+++ b/src/src/transports/autoreply.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/transports/lmtp.c b/src/src/transports/lmtp.c
index f26050fdc..de1ee166b 100644
--- a/src/src/transports/lmtp.c
+++ b/src/src/transports/lmtp.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2016 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/transports/pipe.c b/src/src/transports/pipe.c
index 0ce281fd0..5b7fa1f5c 100644
--- a/src/src/transports/pipe.c
+++ b/src/src/transports/pipe.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2015 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/transports/queuefile.c b/src/src/transports/queuefile.c
index bc4ed3f40..4a74c752a 100644
--- a/src/src/transports/queuefile.c
+++ b/src/src/transports/queuefile.c
@@ -4,6 +4,7 @@
/* Copyright (c) Andrew Colin Kissa <andrew@topdog.za.net> 2016 */
/* Copyright (c) University of Cambridge 2016 */
+/* Copyright (c) The Exim Maintainers 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c
index 14cfde72a..9dc632e7f 100644
--- a/src/src/transports/smtp.c
+++ b/src/src/transports/smtp.c
@@ -1820,7 +1820,7 @@ goto SEND_QUIT;
errno = ERRNO_SMTPCLOSED;
goto EHLOHELO_FAILED;
}
- Ustrncpy(sx->buffer, rsp, sizeof(sx->buffer)/2);
+ memmove(sx->buffer, rsp, Ustrlen(rsp));
goto RESPONSE_FAILED;
}
}
@@ -2176,11 +2176,6 @@ return OK;
sx->send_quit = FALSE;
goto FAILED;
- /* This label is jumped to directly when a TLS negotiation has failed,
- or was not done for a host for which it is required. Values will be set
- in message and errno, and setting_up will always be true. Treat as
- a temporary error. */
-
EHLOHELO_FAILED:
code = '4';
message = string_sprintf("Remote host closed connection in response to %s"
@@ -2188,6 +2183,11 @@ return OK;
sx->send_quit = FALSE;
goto FAILED;
+ /* This label is jumped to directly when a TLS negotiation has failed,
+ or was not done for a host for which it is required. Values will be set
+ in message and errno, and setting_up will always be true. Treat as
+ a temporary error. */
+
#ifdef SUPPORT_TLS
TLS_FAILED:
code = '4';
@@ -2580,29 +2580,37 @@ return 0;
* Proxy TLS connection for another transport process *
******************************************************/
/*
-Use the given buffer as a staging area, and select on both the given fd
-and the TLS'd client-fd for data to read (per the coding in ip_recv() and
-fd_ready() this is legitimate). Do blocking full-size writes, and reads
-under a timeout.
+Close the unused end of the pipe, fork once more, then use the given buffer
+as a staging area, and select on both the given fd and the TLS'd client-fd for
+data to read (per the coding in ip_recv() and fd_ready() this is legitimate).
+Do blocking full-size writes, and reads under a timeout. Once both input
+channels are closed, exit the process.
Arguments:
buf space to use for buffering
bufsiz size of buffer
- proxy_fd comms to proxied process
+ pfd pipe filedescriptor array; [0] is comms to proxied process
timeout per-read timeout, seconds
*/
void
-smtp_proxy_tls(uschar * buf, size_t bsize, int proxy_fd, int timeout)
+smtp_proxy_tls(uschar * buf, size_t bsize, int * pfd, int timeout)
{
fd_set rfds, efds;
-int max_fd = MAX(proxy_fd, tls_out.active) + 1;
+int max_fd = MAX(pfd[0], tls_out.active) + 1;
int rc, i, fd_bits, nbytes;
+close(pfd[1]);
+if ((rc = fork()))
+ {
+ DEBUG(D_transport) debug_printf("proxy-proc final-pid %d\n", rc);
+ _exit(rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS);
+ }
+
set_process_info("proxying TLS connection for continued transport");
FD_ZERO(&rfds);
FD_SET(tls_out.active, &rfds);
-FD_SET(proxy_fd, &rfds);
+FD_SET(pfd[0], &rfds);
for (fd_bits = 3; fd_bits; )
{
@@ -2624,17 +2632,17 @@ for (fd_bits = 3; fd_bits; )
if (rc <= 0)
{
DEBUG(D_transport) if (rc == 0) debug_printf("%s: timed out\n", __FUNCTION__);
- return;
+ goto done;
}
- if (FD_ISSET(tls_out.active, &efds) || FD_ISSET(proxy_fd, &efds))
+ if (FD_ISSET(tls_out.active, &efds) || FD_ISSET(pfd[0], &efds))
{
DEBUG(D_transport) debug_printf("select: exceptional cond on %s fd\n",
- FD_ISSET(proxy_fd, &efds) ? "proxy" : "tls");
- return;
+ FD_ISSET(pfd[0], &efds) ? "proxy" : "tls");
+ goto done;
}
}
- while (rc < 0 || !(FD_ISSET(tls_out.active, &rfds) || FD_ISSET(proxy_fd, &rfds)));
+ while (rc < 0 || !(FD_ISSET(tls_out.active, &rfds) || FD_ISSET(pfd[0], &rfds)));
/* handle inbound data */
if (FD_ISSET(tls_out.active, &rfds))
@@ -2642,20 +2650,20 @@ for (fd_bits = 3; fd_bits; )
{
fd_bits &= ~1;
FD_CLR(tls_out.active, &rfds);
- shutdown(proxy_fd, SHUT_WR);
+ shutdown(pfd[0], SHUT_WR);
timeout = 5;
}
else
{
for (nbytes = 0; rc - nbytes > 0; nbytes += i)
- if ((i = write(proxy_fd, buf + nbytes, rc - nbytes)) < 0) return;
+ if ((i = write(pfd[0], buf + nbytes, rc - nbytes)) < 0) goto done;
}
else if (fd_bits & 1)
FD_SET(tls_out.active, &rfds);
/* handle outbound data */
- if (FD_ISSET(proxy_fd, &rfds))
- if ((rc = read(proxy_fd, buf, bsize)) <= 0)
+ if (FD_ISSET(pfd[0], &rfds))
+ if ((rc = read(pfd[0], buf, bsize)) <= 0)
{
fd_bits = 0;
tls_close(FALSE, TRUE);
@@ -2664,11 +2672,15 @@ for (fd_bits = 3; fd_bits; )
{
for (nbytes = 0; rc - nbytes > 0; nbytes += i)
if ((i = tls_write(FALSE, buf + nbytes, rc - nbytes, FALSE)) < 0)
- return;
+ goto done;
}
else if (fd_bits & 2)
- FD_SET(proxy_fd, &rfds);
+ FD_SET(pfd[0], &rfds);
}
+
+done:
+ if (running_in_test_harness) millisleep(100); /* let logging complete */
+ exim_exit(0, US"TLS proxy");
}
#endif
@@ -3153,7 +3165,7 @@ else
else
sprintf(CS sx.buffer, "%.500s\n", addr->unique);
- DEBUG(D_deliver) debug_printf("S:journalling %s", sx.buffer);
+ DEBUG(D_deliver) debug_printf("S:journalling %s\n", sx.buffer);
len = Ustrlen(CS sx.buffer);
if (write(journal_fd, sx.buffer, len) != len)
log_write(0, LOG_MAIN|LOG_PANIC, "failed to write journal for "
@@ -3485,7 +3497,8 @@ propagate it from the initial
{
sx.send_quit = FALSE;
- /* If TLS is still active, we need to proxy it for the transport we
+ /* We have passed the client socket to a fresh transport process.
+ If TLS is still active, we need to proxy it for the transport we
just passed the baton to. Fork a child to to do it, and return to
get logging done asap. Which way to place the work makes assumptions
about post-fork prioritisation which may not hold on all platforms. */
@@ -3493,10 +3506,16 @@ propagate it from the initial
if (tls_out.active >= 0)
{
int pid = fork();
+ if (pid == 0) /* child; fork again to disconnect totally */
+ /* does not return */
+ smtp_proxy_tls(sx.buffer, sizeof(sx.buffer), pfd,
+ sx.ob->command_timeout);
+
if (pid > 0) /* parent */
{
DEBUG(D_transport) debug_printf("proxy-proc inter-pid %d\n", pid);
close(pfd[0]);
+ /* tidy the inter-proc to disconn the proxy proc */
waitpid(pid, NULL, 0);
tls_close(FALSE, FALSE);
(void)close(sx.inblock.sock);
@@ -3504,17 +3523,7 @@ propagate it from the initial
continue_hostname = NULL;
return yield;
}
- else if (pid == 0) /* child; fork again to disconnect totally */
- {
- close(pfd[1]);
- if ((pid = fork()))
- {
- DEBUG(D_transport) debug_printf("proxy-prox final-pid %d\n", pid);
- _exit(pid ? EXIT_FAILURE : EXIT_SUCCESS);
- }
- smtp_proxy_tls(sx.buffer, sizeof(sx.buffer), pfd[0], sx.ob->command_timeout);
- exim_exit(0);
- }
+ log_write(0, LOG_PANIC_DIE, "fork failed");
}
#endif
}
diff --git a/src/src/transports/smtp_socks.c b/src/src/transports/smtp_socks.c
index c9907dd54..5eee220a5 100644
--- a/src/src/transports/smtp_socks.c
+++ b/src/src/transports/smtp_socks.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) Jeremy Harris 2015 */
+/* Copyright (c) Jeremy Harris 2015 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* SOCKS version 5 proxy, client-mode */
@@ -74,8 +74,6 @@ sob->priority = SOCKS_PRIORITY;
static void
socks_option(socks_opts * sob, const uschar * opt)
{
-const uschar * s;
-
if (Ustrncmp(opt, "auth=", 5) == 0)
{
opt += 5;
diff --git a/src/src/transports/tf_maildir.c b/src/src/transports/tf_maildir.c
index 9e18a804b..d970156be 100644
--- a/src/src/transports/tf_maildir.c
+++ b/src/src/transports/tf_maildir.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2014 */
+/* Copyright (c) University of Cambridge 1995 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Functions in support of the use of maildirsize files for handling quotas in
diff --git a/src/src/utf8.c b/src/src/utf8.c
index dcc944af9..cf010283b 100644
--- a/src/src/utf8.c
+++ b/src/src/utf8.c
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) Jeremy Harris 2015, 2016 */
+/* Copyright (c) Jeremy Harris 2015 - 2017 */
/* See the file NOTICE for conditions of use and distribution. */
diff --git a/src/src/verify.c b/src/src/verify.c
index ac5eb667b..b957c709b 100644
--- a/src/src/verify.c
+++ b/src/src/verify.c
@@ -2263,7 +2263,7 @@ for (h = header_list; h != NULL && yield == OK; h = h->next)
/* deconst cast ok as we're passing a non-const to string_printing() */
*msgptr = US string_printing(
string_sprintf("%s: failing address in \"%.*s:\" header %s: %.*s",
- errmess, tt - h->text, h->text, verb, len, s));
+ errmess, (int)(tt - h->text), h->text, verb, len, s));
yield = FAIL;
break; /* Out of address loop */
@@ -2564,7 +2564,7 @@ for (i = 0; i < 3 && !done; i++)
while (ss > s && isspace(ss[-1])) ss--;
*log_msgptr = string_sprintf("syntax error in '%.*s' header when "
"scanning for sender: %s in \"%.*s\"",
- endname - h->text, h->text, *log_msgptr, ss - s, s);
+ (int)(endname - h->text), h->text, *log_msgptr, (int)(ss - s), s);
yield = FAIL;
done = TRUE;
break;
@@ -2592,11 +2592,9 @@ for (i = 0; i < 3 && !done; i++)
{
*verrno = vaddr->basic_errno;
if (smtp_return_error_details)
- {
*user_msgptr = string_sprintf("Rejected after DATA: "
"could not verify \"%.*s\" header address\n%s: %s",
- endname - h->text, h->text, vaddr->address, vaddr->message);
- }
+ (int)(endname - h->text), h->text, vaddr->address, vaddr->message);
}
/* Success or defer */
@@ -2657,6 +2655,7 @@ verify_get_ident(int port)
int sock, host_af, qlen;
int received_sender_port, received_interface_port, n;
uschar *p;
+blob early_data;
uschar buffer[2048];
/* Default is no ident. Check whether we want to do an ident check for this
@@ -2682,11 +2681,15 @@ if (ip_bind(sock, host_af, interface_address, 0) < 0)
goto END_OFF;
}
-/*XXX could take advantage of TFO early-data. Hmm, what are the
-error returns; can we differentiate connect from data fails?
-Do we need to? */
+/* Construct and send the query. */
+
+qlen = snprintf(CS buffer, sizeof(buffer), "%d , %d\r\n",
+ sender_host_port, interface_port);
+early_data.data = buffer;
+early_data.len = qlen;
+
if (ip_connect(sock, host_af, sender_host_address, port,
- rfc1413_query_timeout, &tcp_fastopen_nodata) < 0)
+ rfc1413_query_timeout, &early_data) < 0)
{
if (errno == ETIMEDOUT && LOGGING(ident_timeout))
log_write(0, LOG_MAIN, "ident connection to %s timed out",
@@ -2697,16 +2700,6 @@ if (ip_connect(sock, host_af, sender_host_address, port,
goto END_OFF;
}
-/* Construct and send the query. */
-
-sprintf(CS buffer, "%d , %d\r\n", sender_host_port, interface_port);
-qlen = Ustrlen(buffer);
-if (send(sock, buffer, qlen, 0) < 0)
- {
- DEBUG(D_ident) debug_printf("ident send failed: %s\n", strerror(errno));
- goto END_OFF;
- }
-
/* Read a response line. We put it into the rest of the buffer, using several
recv() calls if necessary. */
diff --git a/src/src/version.c b/src/src/version.c
index f27cc3cde..822323627 100644
--- a/src/src/version.c
+++ b/src/src/version.c
@@ -3,6 +3,7 @@
*************************************************/
/* Copyright (c) University of Cambridge 1995 - 2009 */
+/* Copyright (c) The Exim Maintainers 2017 */
/* See the file NOTICE for conditions of use and distribution. */
/* Function for setting up the version string. */