From: Jeremy Harris Date: Thu, 26 May 2022 11:10:27 +0000 (+0100) Subject: DEBUG: clarify multiline smtp responses X-Git-Tag: exim-4.96-RC2~10 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/df12cced099ee64551adf71b5fa38695db62c3f9 DEBUG: clarify multiline smtp responses --- diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c index 6de85a15f..7a4eaf996 100644 --- a/src/src/smtp_in.c +++ b/src/src/smtp_in.c @@ -956,15 +956,12 @@ that we'll never expand it. */ yield = !! string_vformat(&gs, SVFMT_TAINT_NOCHK, format, ap); string_from_gstring(&gs); -DEBUG(D_receive) - { - uschar *msg_copy, *cr, *end; - msg_copy = string_copy(gs.s); - end = msg_copy + gs.ptr; - while ((cr = Ustrchr(msg_copy, '\r')) != NULL) /* lose CRs */ - memmove(cr, cr + 1, (end--) - cr); - debug_printf("SMTP>> %s", msg_copy); - } +DEBUG(D_receive) for (const uschar * t, * s = gs.s; + s && (t = Ustrchr(s, '\r')); + s = t + 2) /* \r\n */ + debug_printf("%s %.*s\n", + s == gs.s ? "SMTP>>" : " ", + (int)(t - s), s); if (!yield) { @@ -4622,15 +4619,12 @@ while (done <= 0) #endif (void) fwrite(g->s, 1, g->ptr, smtp_out); - DEBUG(D_receive) - { - uschar *cr; - - (void) string_from_gstring(g); - while ((cr = Ustrchr(g->s, '\r')) != NULL) /* lose CRs */ - memmove(cr, cr + 1, (g->ptr--) - (cr - g->s)); - debug_printf("SMTP>> %s", g->s); - } + DEBUG(D_receive) for (const uschar * t, * s = string_from_gstring(g); + s && (t = Ustrchr(s, '\r')); + s = t + 2) /* \r\n */ + debug_printf("%s %.*s\n", + s == g->s ? "SMTP>>" : " ", + (int)(t - s), s); fl.helo_seen = TRUE; /* Reset the protocol and the state, abandoning any previous message. */ diff --git a/test/stderr/0044 b/test/stderr/0044 index 6d3354ece..e8e4a384f 100644 --- a/test/stderr/0044 +++ b/test/stderr/0044 @@ -33,10 +33,10 @@ host in dsn_advertise_hosts? no (option unset) host in pipelining_advertise_hosts? yes (matched "*") host in chunking_advertise_hosts? no (end of list) SMTP>> 250-the.local.host.name Hello exim.test.ex [V4NET.11.12.13] -250-SIZE 52428800 -250-8BITMIME -250-PIPELINING -250 HELP + 250-SIZE 52428800 + 250-8BITMIME + 250-PIPELINING + 250 HELP SMTP<< mail from:postmaster@exim.test.ex spool directory space = nnnnnK inodes = nnnnn check_space = 10240K inodes = 100 msg_size = 0 log directory space = nnnnnK inodes = nnnnn check_space = 10240K inodes = 100 @@ -211,10 +211,10 @@ host in dsn_advertise_hosts? no (option unset) host in pipelining_advertise_hosts? yes (matched "*") host in chunking_advertise_hosts? no (end of list) SMTP>> 250-the.local.host.name Hello exim.test.ex [V4NET.99.99.99] -250-SIZE 52428800 -250-8BITMIME -250-PIPELINING -250 HELP + 250-SIZE 52428800 + 250-8BITMIME + 250-PIPELINING + 250 HELP SMTP<< mail from:postmaster@exim.test.ex spool directory space = nnnnnK inodes = nnnnn check_space = 10240K inodes = 100 msg_size = 0 log directory space = nnnnnK inodes = nnnnn check_space = 10240K inodes = 100 diff --git a/test/stderr/0303 b/test/stderr/0303 index d8c1e68da..bf8f94662 100644 --- a/test/stderr/0303 +++ b/test/stderr/0303 @@ -72,10 +72,10 @@ host in dsn_advertise_hosts? no (option unset) host in pipelining_advertise_hosts? yes (matched "*") host in chunking_advertise_hosts? no (end of list) SMTP>> 250-myhost.test.ex Hello [V4NET.2.3.4] [V4NET.2.3.4] -250-SIZE 52428800 -250-8BITMIME -250-PIPELINING -250 HELP + 250-SIZE 52428800 + 250-8BITMIME + 250-PIPELINING + 250 HELP SMTP<< mail from:<> spool directory space = nnnnnK inodes = nnnnn check_space = 10240K inodes = 100 msg_size = 0 log directory space = nnnnnK inodes = nnnnn check_space = 10240K inodes = 100 @@ -149,10 +149,10 @@ host in dsn_advertise_hosts? no (option unset) host in pipelining_advertise_hosts? yes (matched "*") host in chunking_advertise_hosts? no (end of list) SMTP>> 250-myhost.test.ex Hello host.name.tld [V4NET.2.3.4] -250-SIZE 52428800 -250-8BITMIME -250-PIPELINING -250 HELP + 250-SIZE 52428800 + 250-8BITMIME + 250-PIPELINING + 250 HELP SMTP<< mail from:<> spool directory space = nnnnnK inodes = nnnnn check_space = 10240K inodes = 100 msg_size = 0 log directory space = nnnnnK inodes = nnnnn check_space = 10240K inodes = 100 diff --git a/test/stderr/0371 b/test/stderr/0371 index 9a3402fe5..41ad3ff50 100644 --- a/test/stderr/0371 +++ b/test/stderr/0371 @@ -39,11 +39,11 @@ host in dsn_advertise_hosts? no (option unset) host in pipelining_advertise_hosts? yes (matched "*") host in chunking_advertise_hosts? no (end of list) SMTP>> 250-mail.test.ex Hello something [V4NET.0.0.0] -250-SIZE 52428800 -250-8BITMIME -250-VRFY -250-PIPELINING -250 HELP + 250-SIZE 52428800 + 250-8BITMIME + 250-VRFY + 250-PIPELINING + 250 HELP SMTP<< mail from: spool directory space = nnnnnK inodes = nnnnn check_space = 10240K inodes = 100 msg_size = 0 log directory space = nnnnnK inodes = nnnnn check_space = 10240K inodes = 100 diff --git a/test/stderr/0487 b/test/stderr/0487 index 2056f5373..5b9855f4a 100644 --- a/test/stderr/0487 +++ b/test/stderr/0487 @@ -23,10 +23,10 @@ SMTP<< ehlo x.y in pipelining_advertise_hosts? yes (matched "*") in chunking_advertise_hosts? no (end of list) SMTP>> 250-myhost.test.ex Hello CALLER at x.y -250-SIZE 52428800 -250-8BITMIME -250-PIPELINING -250 HELP + 250-SIZE 52428800 + 250-8BITMIME + 250-PIPELINING + 250 HELP SMTP<< mail from: spool directory space = nnnnnK inodes = nnnnn check_space = 10240K inodes = 100 msg_size = 0 log directory space = nnnnnK inodes = nnnnn check_space = 10240K inodes = 100 diff --git a/test/stderr/3400 b/test/stderr/3400 index bd048d486..bec165e5d 100644 --- a/test/stderr/3400 +++ b/test/stderr/3400 @@ -448,14 +448,14 @@ Evaluating advertise_condition for defer DEFER athenticator Evaluating advertise_condition for login LOGIN athenticator host in chunking_advertise_hosts? no (end of list) SMTP>> 250-myhost.test.ex Hello CALLER at testing.testing [10.0.0.5] -250-SIZE 52428800 -250-8BITMIME -250-ETRN -250-VRFY -250-EXPN -250-PIPELINING -250-AUTH MYLOGIN PLAIN EXPLAIN EXPANDED EXPANDFAIL DEFER LOGIN -250 HELP + 250-SIZE 52428800 + 250-8BITMIME + 250-ETRN + 250-VRFY + 250-EXPN + 250-PIPELINING + 250-AUTH MYLOGIN PLAIN EXPLAIN EXPANDED EXPANDFAIL DEFER LOGIN + 250 HELP SMTP<< auth mylogin dXNlcnggc2VjcmV0 auth input decode: 'userx secret' mylogin authenticator server_condition: