summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2012-10-04 22:21:09 +0100
committerJeremy Harris <jgh146exb@wizmail.org>2012-10-04 22:43:51 +0100
commitb1b05573117d62c3b95d854d8ac5a447df19e82e (patch)
treee05a6de8b3735794ebcb0194974ca6934b8c75ca /src
parent40167b055c6f7c2168941524ca6af08674dfbbb7 (diff)
Strip leading/trailing newlines on list of headers for addition; bug 884.
NB: this means a bare "X-ACL-Warn:" header is harder to add.
Diffstat (limited to 'src')
-rw-r--r--src/src/acl.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/src/acl.c b/src/src/acl.c
index 3b23a915b..f9a32d3b7 100644
--- a/src/src/acl.c
+++ b/src/src/acl.c
@@ -958,10 +958,13 @@ setup_header(uschar *hstring)
uschar *p, *q;
int hlen = Ustrlen(hstring);
-/* An empty string does nothing; otherwise add a final newline if necessary. */
+/* Ignore any leading newlines */
+while (*hstring == '\n') hstring++, hlen--;
+/* An empty string does nothing; ensure exactly one final newline. */
if (hlen <= 0) return;
-if (hstring[hlen-1] != '\n') hstring = string_sprintf("%s\n", hstring);
+if (hstring[--hlen] != '\n') hstring = string_sprintf("%s\n", hstring);
+else while(hstring[--hlen] == '\n') hstring[hlen+1] = '\0';
/* Loop for multiple header lines, taking care about continuations */