Arne Ansper wrote:
> > > 8) ssl/s2_pkt.c and ssl/s3_pkt.c write_pending and
> > > ssl3_write_pending have unnecessary check at the beginning which stops
> > > me from moving data around in my buffers between calls to SSL_write.
> > > this data is already copied to internal buffers and there is no need
> > > for this check. i tested ssleay without this check (non-blocking
> > > sockets and stuff) under various platforms and everything worked as
> > > expected.
> 
> > I'm reluctant to commit this. It seems to me that you need to find a way
> > to fix things up if you move data around (why do you do that anyway?).
> 
> ok i try to make little example:
> 
> /* s is non-blocking SSL socket which is full: i.e. write will fail with
> EAGAIN */
> int f(SSL* s)
> {
>         char a[3];
> 
>         a[0]= 'a';
>         SSL_write(s, a, 1);     /* returns -1 */
> 
>         /* now i have a complete SSL record somewhere inside s, which is
>         not sent */
> 
>         sleep(1000);    /* wait and let the socket drain */
>         a[1]= 'b';
>         SSL_write(s, a, 2);
> 
>         /* this call will now fail with bad write retry, but instead
>         it should write the previous record into socket, mark 1 byte as
>         written (this is done in ssl3_write_bytes), create another record
>         from remainig byte and try to write it into socket. and then if
>         last write succceds report 2 bytes written if write fails then
>         none.
> 
>         if i remove the check then this function works as i just
>         described */
> }
> 
> btw, in SSLeay 0.9.0 this check is marked with /* XXX */ -- looks like
> some kind of todo marker.

I can't see the problem here. The check is:

        if ((s->s2->wpend_tot > (int)len) || (s->s2->wpend_buf != buf))

At the second call of SSL_write s->s2_wpend->tot should be 1, len should
be 2, s->s2->wpend_buf should be a and buf should be a, so the test
should not fail (I have to say that converting len to an int rather
ruins the point of it being unsigned in the first place, though!).

Perhaps you oversimplified your example?

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
     - Indira Ghandi
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to