Mailing List Archive

bug (and possible fix) in qmail-smtputf8.patch
[.I've already corresponded directly with the patch author, who's on vacation. In the meantime, in case anyone's using the patch, I wanted to share my findings with this list.]

Arnt Gulbrandsen wrote a UTF-8 "Email Address Internationalization" patch for qmail-smtpd and qmail-remote. It was relatively recently added to the "Recommended patches" here: http://www.qmail.org/top.html#patches

I haven't noticed any problems with qmail-smtpd, but I think the patch adds a bug to qmail-remote.

To reproduce the bug:

1. Install a vanilla netqmail into /var/qmail-there

2. Apply the EAI patch, then install into /var/qmail-here

3. In /var/qmail-here/control/smtproutes, set qmail-there as qmail-here's smarthost

4. Run /var/qmail-there/bin/qmail-smtpd, wrapped in recordio

5. Run /var/qmail-here/bin/qmail-inject, sending to postmaster@qmail-there

6. Note that the message stays in qmail-here's queue

7. Inspect qmail-there's qmail-smtpd log

8. Observe that SMTP commands and message body lines are CRLF-terminated, but header lines are bare-LF-terminated

Temporarily wrapping qmail-there's qmail-smtpd with fixcrio then allows the message through.

The problem does not depend on whether the message is ASCII-only or UTF-8.

My analysis: qmail-remote.c:blast() normally munges every LF into CRLF. But when the EAI patch adds a "firstpart", those line endings don't get munged in the same way. The one-liner below munges firstpart's line endings a bit earlier. It appears to fix my bug, and maybe doesn't introduce new ones.

I trust Arnt to look at this when he returns from vacation and issue an official fix. In the meantime, perhaps this helps someone.

- Amitai


--- qmail-remote.c.orig 2017-07-30 18:24:37.000000000 +0000
+++ qmail-remote.c
@@ -253,6 +253,7 @@ void checkutf8message()
if (r == 0) break;
if (r == -1) temp_read();

+ if (ch == '\n' && !stralloc_append(&firstpart,"\r")) temp_nomem();
if (!stralloc_append(&firstpart,&ch)) temp_nomem();

if (ch == '\r')
Re: bug (and possible fix) in qmail-smtputf8.patch [ In reply to ]
Hi Amitai,

again, the patch is broken. CR ist missing for the received header written.

A correct and far more easy implementation can be found here:

http://www.fehcom.de/sqmail/doxygen/qmail-remote_8c.html

The author never tried his patch against an other qmail MTA ;-)

Regards.
--eh.



> Am 16.08.2017 um 19:14 schrieb Amitai Schleier <schmonz@schmonz.com>:
>
> [.I've already corresponded directly with the patch author, who's on vacation. In the meantime, in case anyone's using the patch, I wanted to share my findings with this list.]
>
> Arnt Gulbrandsen wrote a UTF-8 "Email Address Internationalization" patch for qmail-smtpd and qmail-remote. It was relatively recently added to the "Recommended patches" here: http://www.qmail.org/top.html#patches
>
> I haven't noticed any problems with qmail-smtpd, but I think the patch adds a bug to qmail-remote.
>
> To reproduce the bug:
>
> 1. Install a vanilla netqmail into /var/qmail-there
>
> 2. Apply the EAI patch, then install into /var/qmail-here
>
> 3. In /var/qmail-here/control/smtproutes, set qmail-there as qmail-here's smarthost
>
> 4. Run /var/qmail-there/bin/qmail-smtpd, wrapped in recordio
>
> 5. Run /var/qmail-here/bin/qmail-inject, sending to postmaster@qmail-there
>
> 6. Note that the message stays in qmail-here's queue
>
> 7. Inspect qmail-there's qmail-smtpd log
>
> 8. Observe that SMTP commands and message body lines are CRLF-terminated, but header lines are bare-LF-terminated
>
> Temporarily wrapping qmail-there's qmail-smtpd with fixcrio then allows the message through.
>
> The problem does not depend on whether the message is ASCII-only or UTF-8.
>
> My analysis: qmail-remote.c:blast() normally munges every LF into CRLF. But when the EAI patch adds a "firstpart", those line endings don't get munged in the same way. The one-liner below munges firstpart's line endings a bit earlier. It appears to fix my bug, and maybe doesn't introduce new ones.
>
> I trust Arnt to look at this when he returns from vacation and issue an official fix. In the meantime, perhaps this helps someone.
>
> - Amitai
>
>
> --- qmail-remote.c.orig 2017-07-30 18:24:37.000000000 +0000
> +++ qmail-remote.c
> @@ -253,6 +253,7 @@ void checkutf8message()
> if (r == 0) break;
> if (r == -1) temp_read();
>
> + if (ch == '\n' && !stralloc_append(&firstpart,"\r")) temp_nomem();
> if (!stralloc_append(&firstpart,&ch)) temp_nomem();
>
> if (ch == '\r')

Dr. Erwin Hoffmann | FEHCom | http://www.fehcom.de | PGP Key-Id: EE00CF65