Re: [EXIM] Return value from send(,"MAIL FROM:...",,) not ch…

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Philip Hazel
Date:  
À: Ian Jackson
CC: exim-users
Sujet: Re: [EXIM] Return value from send(,"MAIL FROM:...",,) not checked ?!
On Wed, 25 Mar 1998, Ian Jackson wrote:

> I was playing around with the `internal-only' -MC option and was
> slightly confused by its behaviour when stdin/out is a tty. So, I
> straced it and found ...


Hmm. Sometimes I wonder if my "document everything" policy is actually
such a good idea...

> 1998-03-25 21:42:32 0yHxrt-000053-00 == ian@??? T=smtp defe
> r (88): Socket operation on non-socket: host davenant.davenant.greenend.org.uk [
> 172.18.45.1]: Socket operation on non-socket


Yes, well, it expects to be given a socket. That's the spec.

> Does it make the same mistake with message body text ?!


No. Otherwise it would't be working right with (e.g.) over-quota
failures.

> How many other places in the Exim source code are the return values
> from system calls not checked ?!


I don't know! I regret that I'm not infallible.

> I have to say that I think this kind
> of thing is completely unacceptable in a program not written by
> tripped-out BSD hackers ...


I am wearing sackcloth and will scour the neighbourhood for ashes as a
result of the coming to light of this horrible oversight, which dates
from very early on in the development of Exim. I have also made a note
to fix it, but it won't be in the next release.

> On an aside, is there any reason why you're using send() here instead
> of write ? It seems to me that the error behaviour of send() is
> unhelpful if you want to use non-blocking I/O (as you seem to), given
> the use of select(). In particular, it seems to want to send the data
> all at once, so it seems that you could loop with send returning
> EWOULDBLOCK but select returning ready-for-writing.


I cannot remember why send() is used for SMTP commands. For the content
of the message, write() is used. However, they are all blocking writes.
The use of select() is for reading the responses. The comment in the
code says

/* Loop for handling SMTP responses that do not all come in one packet  
(multiline or otherwise). Each call to recv is timed by means of the
timeout in the select() function. This works on all OS - and is more    
efficient that the use of signal() and alarm(). */              


> Also, I can think of weird things that could be done with -MC which
> would be harder if you have to make sure that the descriptor can be
> used with send() rather than just write().


Boggle.

-- 
Philip Hazel                   University Computing Service,
ph10@???             New Museums Site, Cambridge CB2 3QG,
P.Hazel@???          England.  Phone: +44 1223 334714



--
*** Exim information can be found at http://www.exim.org/ ***