bug in v3.4.4 (and v3.6.0) lmtpd?

IMAP List Administration <[email protected]>
Newsgroups gmane.mail.imap.cyrus
Message-ID <[email protected]>
Hello,

as mentioned in the post from December 30th, 2022, (Subject: "Cyrus IMAP error 
(?): 'Undefined error 0'..."), we've been seeing the following response from the 
Cyrus imapd for successful delivery to a mailbox:

> 250 2.1.5 Undefined error: 0 
> SESSIONID=<imapd-1672619404-57025-2-15431856533157375633>

I started digging in the sources and found that between 3.0.8 and 3.4.4 the 
following code was added to the top of lmtpengine.c:send_lmtp_error():

>     int code;
>
>     if (resp) {
>         int i;
>
>         for (i = 0; i < strarray_size(resp); i++) {
>             prot_puts(pout, strarray_nth(resp, i));
>         }
>         return;
>     }

Presumably the "prot_puts(pout, strarray_nth(resp, i));" would emit the correct 
success notification ("250 2.1.5 Ok SESSIONID=<sess-id>"), but this depends on 
"resp" being non-null, however, in lmtpd.c:deliver(), in near the bottom of the 
loop which iterates through all the recipients, we see this line:

>         msg_setrcpt_status(msgdata, n, r, NULL);

Which causes msg_setrcpt_status() to always assign:

     m->rcpt[rcpt_num]->resp = NULL;

Because resp is NULL, the "if (resp) {" block in send_lmtp_error() is not 
invoked, and control continues at the switch statement, which tests (r). As r 
contains zero (which indicates no error, I presume), the following matches:

>     case 0:
>         code = LMTP_OK;
>         break;

which causes this:

>     prot_printf(pout, error_message(code), error_message(r), session_id());

to emit the famous "250 2.1.5 Undefined error: 0 SESSIONID=..." line.

This would seem to be a bug.

The 3.0.8 send_lmtp_error() emits the success notification line when r == 0. 
There seem to be some wires crossed about how to propagate success/failure status.

The 3.6.0 code seems to be the same as the 3.4.4 code.

-Rob


------------------------------------------
Cyrus: Info
Permalink: https://cyrus.topicbox.com/groups/info/T98f17a6ea7456fc1-M0902a38fac2c64d3f7fa3643
Delivery options: https://cyrus.topicbox.com/groups/info/subscription
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.