Gitweb:
https://git.exim.org/exim.git/commitdiff/a050bbe0d120464d80dab3eb8af420c4ec686ca8
Commit: a050bbe0d120464d80dab3eb8af420c4ec686ca8
Parent: 599fc3c68f5e942c1d662012053ecfc6ea26bd49
Author: Jeremy Harris <jgh146exb@???>
AuthorDate: Wed May 13 00:58:32 2020 +0100
Committer: Jeremy Harris <jgh146exb@???>
CommitDate: Wed May 13 00:58:32 2020 +0100
Fix over-long line in DSN
---
doc/doc-txt/ChangeLog | 4 ++++
src/src/deliver.c | 24 +++++++++++++++++++-----
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index 3cd92b8..1682a78 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -199,6 +199,10 @@ JH/42 Internationalisation: change the default for downconversion in the smtp
transport. The change does mean that addresses needing conversion will
be converted when previously a delivery failure would occur.
+JH/43 Fix possible long line in DSN. Previously when a very long SMTP error
+ response was received it would be used unchecked in a fail-DSN, violating
+ standards on line-length limits. Truncate if needed.
+
Exim version 4.93
-----------------
diff --git a/src/src/deliver.c b/src/src/deliver.c
index 85b061b..40db500 100644
--- a/src/src/deliver.c
+++ b/src/src/deliver.c
@@ -5380,7 +5380,8 @@ Returns: nothing
static void
print_dsn_diagnostic_code(const address_item *addr, FILE *f)
{
-uschar *s = testflag(addr, af_pass_message) ? addr->message : NULL;
+uschar * s = testflag(addr, af_pass_message) ? addr->message : NULL;
+unsigned cnt;
/* af_pass_message and addr->message set ? print remote host answer */
if (s)
@@ -5392,19 +5393,32 @@ if (s)
if (!(s = Ustrstr(addr->message, ": ")))
return; /* not found, bail out */
s += 2; /* skip ": " */
- fprintf(f, "Diagnostic-Code: smtp; ");
+ cnt = fprintf(f, "Diagnostic-Code: smtp; ");
}
/* no message available. do nothing */
else return;
while (*s)
+ {
+ if (cnt > 950) /* RFC line length limit: 998 */
+ {
+ DEBUG(D_deliver) debug_printf("print_dsn_diagnostic_code() truncated line\n");
+ fputs("[truncated]", f);
+ break;
+ }
+
if (*s == '\\' && s[1] == 'n')
{
fputs("\n ", f); /* as defined in RFC 3461 */
s += 2;
+ cnt += 2;
}
else
+ {
fputc(*s++, f);
+ cnt++;
+ }
+ }
fputc('\n', f);
}
@@ -7831,11 +7845,11 @@ wording. */
fprintf(fp, "Remote-MTA: X-ip; [%s]%s\n", hu->address, p);
}
if ((s = addr->smtp_greeting) && *s)
- fprintf(fp, "X-Remote-MTA-smtp-greeting: X-str; %s\n", s);
+ fprintf(fp, "X-Remote-MTA-smtp-greeting: X-str; %.900s\n", s);
if ((s = addr->helo_response) && *s)
- fprintf(fp, "X-Remote-MTA-helo-response: X-str; %s\n", s);
+ fprintf(fp, "X-Remote-MTA-helo-response: X-str; %.900s\n", s);
if ((s = addr->message) && *s)
- fprintf(fp, "X-Exim-Diagnostic: X-str; %s\n", s);
+ fprintf(fp, "X-Exim-Diagnostic: X-str; %.900s\n", s);
}
#endif
print_dsn_diagnostic_code(addr, fp);