From af542dcfa62fc2341e8253f10c5c778b887444b9 Mon Sep 17 00:00:00 2001 From: "Heiko Schlittermann (HS12-RIPE)" Date: Sun, 25 Jun 2017 23:35:06 +0200 Subject: [PATCH] Bail out if a configuration file starts with a byte order mark --- src/src/readconf.c | 5 +++++ test/confs/0907 | 3 +++ test/confs/0908 | 1 + test/scripts/0000-Basic/0907 | 4 ++++ test/scripts/0000-Basic/0908 | 1 + test/stderr/0907 | 2 ++ test/stderr/0908 | 2 ++ 7 files changed, 18 insertions(+) create mode 100644 test/confs/0907 create mode 100644 test/confs/0908 create mode 100644 test/scripts/0000-Basic/0907 create mode 120000 test/scripts/0000-Basic/0908 create mode 100644 test/stderr/0907 create mode 100644 test/stderr/0908 diff --git a/src/src/readconf.c b/src/src/readconf.c index 95abaf5be..fd9657e0e 100644 --- a/src/src/readconf.c +++ b/src/src/readconf.c @@ -3469,6 +3469,11 @@ a macro definition. */ while ((s = get_config_line()) != NULL) { + + 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)"); + if (isupper(s[0])) read_macro_assignment(s); else if (Ustrncmp(s, "domainlist", 10) == 0) diff --git a/test/confs/0907 b/test/confs/0907 new file mode 100644 index 000000000..8cb2b1b6d --- /dev/null +++ b/test/confs/0907 @@ -0,0 +1,3 @@ +# This file contains a BOM at the very beginning +tls_advertise_hosts = +keep_environment = diff --git a/test/confs/0908 b/test/confs/0908 new file mode 100644 index 000000000..27af1d5f2 --- /dev/null +++ b/test/confs/0908 @@ -0,0 +1 @@ +.include DIR/confs/0907 diff --git a/test/scripts/0000-Basic/0907 b/test/scripts/0000-Basic/0907 new file mode 100644 index 000000000..341a63f48 --- /dev/null +++ b/test/scripts/0000-Basic/0907 @@ -0,0 +1,4 @@ +# check for BOM in an included config file (0908) +# +1 +exim -bP config diff --git a/test/scripts/0000-Basic/0908 b/test/scripts/0000-Basic/0908 new file mode 120000 index 000000000..8cc1a8c6e --- /dev/null +++ b/test/scripts/0000-Basic/0908 @@ -0,0 +1 @@ +0907 \ No newline at end of file diff --git a/test/stderr/0907 b/test/stderr/0907 new file mode 100644 index 000000000..fe9ba7150 --- /dev/null +++ b/test/stderr/0907 @@ -0,0 +1,2 @@ +1999-03-02 09:44:33 Exim configuration error in line 1 of TESTSUITE/test-config: + found unexpected BOM (Byte Order Mark) diff --git a/test/stderr/0908 b/test/stderr/0908 new file mode 100644 index 000000000..ad35a1ae6 --- /dev/null +++ b/test/stderr/0908 @@ -0,0 +1,2 @@ +1999-03-02 09:44:33 Exim configuration error in line 1 of TESTSUITE/confs/0907: + found unexpected BOM (Byte Order Mark) -- 2.25.1