[Avcheck] Small problem -> solution
Michael Tokarev
mjt@tls.msk.ru
Sun, 27 Oct 2002 15:55:46 +0300
Varadi Gabor wrote:
> Hi, all.
>
> I'm found small problema::
> My avcheck send message, but error.
>
> "unexpected smtp response (need 220): 220-gil.axelero.hu......."
>
> This response multiline-banner !! example mail.axelero.hu
Well, avcheck never had a full-featured SMTP client code. A question:
why you use it this way, to talk with "foreign" mailservers? It is
not designed to work with any SMTP server and to deal with various
SMTP protocol qirks, timeouts etc as e.g. postfix's smtp client.
Avcheck's code should be used in the environment with known behaviour.
[]
> I'm written patch for avcheck.c (smtpresp)
>
> This is correct patch ?
No, it isn't.. ;) It shurely may work in this particular
situation, but there are at least several problems:
there may be many lines in a multi-line responses, not limited
to two lines (a criteria is to search for "250 " (with a space,
not "250-") line:
250-line1
250-line2
...
250-lineN
250 last line
the whole response can be greather thtan fixed i/o buffer used
to read it in avcheck (8Kb currently - well, an smtp server that
has longer reply is probably not that good, but that's another
story).
there is no guarantee that the whole response will go in the same
TCP packet, so several reads may be needed instead of one.
Why things are done this way in avcheck? Well, that's simple.
Because I somewhat dislike to use stdio for such a simple task,
and because I can't be sure that stdio on a particular platform
is able to perform simultaneous reads and writes (and whenever
some code is needed to switch a stream from writing to reading
mode and vise versa - I just don't know). Perhaps I'm wrong
here, or maybe just lazy...
The proper fix is to pass FILE* to smtpresp() instead of fd,
and look at real lines and real protocol details.
You're the first who really noticied this misfeature (there
are some caveats in documentation telling that avcheck isn't
a full-featured smtp client, however). Well, maybe it's a
time to break things and implement this missing aspect. But
I'll need testers for at least solaris and freebsd for this
to be done.
> I'm sorry my english.
;) For me, it's pretty ok (mine isn't perfect either... ;)
/mjt