patch against NUL chars

Brasseur Valéry Valery.Brasseur at atosorigin.com
Fri May 16 03:33:30 EDT 2003


some weeks ago I submit a patch to the list for this sort of "bug".
I also have users who receive mail on "one line" !!!!

And for now get them reject like you as "NUL"  instead of "line too long"
;-)

In the archive of the list you should find my mail !!!

Note: I know this render cyrus non RFC compliant but my user need their mail
and I can't change their friends mailer !

valery

> -----Original Message-----
> From: Dmitry Alyabyev [mailto:gw-cyrus at news.kiev.sovam.com]
> Sent: Thursday, May 15, 2003 2:28 PM
> To: info-cyrus at lists.andrew.cmu.edu
> Subject: Re: patch against NUL chars
> 
> 
> Igor Brezac wrote:
> 
> > 
> > On Thu, 8 May 2003, Dmitry Alyabyev wrote:
> > 
> >> Hello,
> >>
> >> Is there a patch for cyrus 2.2 to filter out NUL chars in 
> incoming messages
> >> instead of reject them with note "Message contains NUL chars" ?
> > 
> > MTA can (should, well mail client should not insert nuls to 
> start with)
> > do this for you.  If you use sendmail, add '1' to the cyrus 
> mailer flags.
> > I am not familiar with other MTAs, but I believe exim can 
> do this as well.
> 
> Okay, I have tried the case and set up exim filtering of 
> NUL-chars *but* still
> see these rejections.
> And after looking into cyrus I found the problem.
> 
> imap/spool.c:
> ...
> int spool_copy_msg(struct protstream *fin, FILE *fout, 
> unsigned long *lines)
> {
>     char buf[8192], *p;
>     int r = 0;
>     unsigned long n = 0;
> 
>     /* -2: Might need room to add a \r\n\0 set */
>     while (prot_fgets(buf, sizeof(buf)-2, fin)) {
>         p = buf + strlen(buf) - 1;
>         if (p < buf) {
>             /* buffer start with a \0 */
>             r = IMAP_MESSAGE_CONTAINSNULL;
>             continue; /* need to eat the rest of the message */
>         }
> ...
>         else if (p[0] != '\n') {
>             /* line contained a \0 not at the end */
>             r = IMAP_MESSAGE_CONTAINSNULL;
>             continue;
>         }
> 
> So, if the message contains long (more than 8192 bytes) line 
> the last block
> *will* produce such error message
> 
> According to RFC-2822 such long lines are prohibited:
> > 2.1.1. Line Length Limits
> >
> > There are two limits that this standard places on the 
> number of characters in
> > a line. Each line of characters MUST be no more than 998 
> characters, and
> > SHOULD be no more than 78 characters, excluding the CRLF.
> 
> ... but I still like to put these weak messages into 
> mailboxes without noise :)
> and this is not so trivial as filter out NUL chars on exim
> 
> Any ideas ?
> 
> -- 
> Dimitry
> 
> 




More information about the Info-cyrus mailing list