[IRCServices] modules/mail/smtp.c bug

gregg conklin greco at gate.net
Wed Sep 1 11:41:46 PDT 2004


i was just setting up ircservices today and everything is working great, 
except sending mail out through the relay. i'm running 5.0.38. i apologize 
if this is already know and i'm just cluttering up the list.

i'm using my isp as the relay (mailhost.gate.net:25) and they return 
multiple lines upon connecting.

220-smtp6.mindspring.com ESMTP Exim 3.33 #1 Wed, 01 Sep 2004 14:20:42 -0400
220-NO UCE.  EarthLink does not authorize the use of its computers or network
220 equipment to deliver, accept, transmit, or distribute unsolicited e-mail.

and it seems that smtp.c isn't correctly handling the multiple lines.

around line 177 of smtp.c is
   if (!si->replycode) {
...
    si->replycode = strtol(buf, &s, 10);
...
       si->replychar = buf[3];
}

what's happening is the first time through
220-smtp6.mindspring.com ESMTP Exim 3.33 #1 Wed, 01 Sep 2004 14:20:42 -0400

is getting parsed out as
220 and '-'
the next time through, si->replycode is still 220 so it's not reparsed. the 
third response:
220 equipment to deliver, accept, transmit, or distribute unsolicited e-mail.

should be parsed as 220 and ' ' but it never is.

the 'fix' i implemented here that seems to work was to take the following 
and break it up:

old:
     if (!have_eol || si->replychar != ' ')
         return;

new:
     if (!have_eol)
         return;

     if (si->replychar != ' ')
     {
         si->replycode = 0;
         return;
     }

that should cause si->replycode to be correctly parsed for each received line.

anyway, hope this helps somebody else having the same troubles.

thanks for the ircservices,
-gregg