Re: bug (and possible fix) in qmail-smtputf8.patch

Erwin Hoffmann <[email protected]> Wed, 16 Aug 2017 19:51:07 +0200
Newsgroups gmane.mail.qmail.general
Message-ID <[email protected]>
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 <[email protected]>:
> 
> [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
signature.asc (application/pgp-signature, 842 B)
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - https://gpgtools.org

iQIcBAEBCgAGBQJZlIYMAAoJEIP8+SDuAM9leAEP/jz+lwHeqJRPs/lr5zIMVcUt
HKR8DhXT+EXeuYnJUKO+idUQ54v2bN/KESD7pD1g8HrfJYh0UlgRkIek3buPrjb1
WPZnZrBdeLI8HopXMMBBx4/hbrbxm9Vom5xG439Eh0bWbArZlTjh246c9/tzxgFB
7lUwqNC5PBBb36qvKEqbzBt3s/cpljRATRrKqt0sQjtFKd4WtMKDkWHrETAr7M1O
z3yqISf08qY8kwFxDtHY+2mYmWnDxHrY8XNX/fzhd+iCYoB/ha1bzYDbYyZn5pIY
jx364SChvnxypo/6PS1b9/mn0d7feqfSGXtMiLIXyguSUfRadcxuwiuqGNEOjexV
i6imHlqHWYMWclVN1WOmhNmOqoqgb5tDj99pL+uucgvsTXX2W0U4DA0w/I1b7bj/
RGa/Wq6mwjM2WGDS8DOQDWjm8bY62vCDDZHuDazMHFIHDhHQw9GsWZ3UaKSWnAdb
bBojQ/LiVWrosciM80E3vw2+2pXtVBPELTskJC4hSwrSMVfn4RDnkwszACy6ENrl
c0r2fvnlw7IaegP/x8YoMPIoY7oSQ6h2ltA/f6U9yh7p562cQXGSKys/dphYsUke
HrJcN/ocovUuQzw3rImcsFSTHlbt5qytK8oxo9pWOVJF6wMQbpJBz8BAjbXFurZ7
5HazVrez3zdzrsUjzlHP
=dhvX
-----END PGP SIGNATURE-----