Encryption BIOs misbehave when used with non blocking I/O.

Two fixes:

1. If BIO_write() fails inside enc_write() it should return the
   total number of bytes successfully written.

2. If BIO_write() fails during BIO_flush() it should return immediately
   with the error code: previously it would fall through to the final
   encrypt, corrupting the buffer.
This commit is contained in:
Dr. Stephen Henson 2003-02-27 14:08:44 +00:00
parent 0461b8c90b
commit 57bc7769b7

View File

@ -271,7 +271,7 @@ static int enc_write(BIO *b, const char *in, int inl)
if (i <= 0) if (i <= 0)
{ {
BIO_copy_next_retry(b); BIO_copy_next_retry(b);
return(i); return (ret == inl) ? i : ret - inl;
} }
n-=i; n-=i;
ctx->buf_off+=i; ctx->buf_off+=i;
@ -325,10 +325,7 @@ again:
{ {
i=enc_write(b,NULL,0); i=enc_write(b,NULL,0);
if (i < 0) if (i < 0)
{ return i;
ret=i;
break;
}
} }
if (!ctx->finished) if (!ctx->finished)