aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2003-02-27 14:07:59 +0000
committerDr. Stephen Henson <steve@openssl.org>2003-02-27 14:07:59 +0000
commitb8dc9693a73bb96688c3e8eaac232fc5b2393609 (patch)
tree7d6efc80aea10f5a53bf023b93c1c2f76e921d88
parent6ac26a5ce5e2891c35a283961a5aa0d9dcc65d6e (diff)
downloadopenssl-b8dc9693a73bb96688c3e8eaac232fc5b2393609.zip
openssl-b8dc9693a73bb96688c3e8eaac232fc5b2393609.tar.gz
openssl-b8dc9693a73bb96688c3e8eaac232fc5b2393609.tar.bz2
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.
-rw-r--r--crypto/evp/bio_enc.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/crypto/evp/bio_enc.c b/crypto/evp/bio_enc.c
index 510e1bc..ab81851 100644
--- a/crypto/evp/bio_enc.c
+++ b/crypto/evp/bio_enc.c
@@ -271,7 +271,7 @@ static int enc_write(BIO *b, const char *in, int inl)
if (i <= 0)
{
BIO_copy_next_retry(b);
- return(i);
+ return (ret == inl) ? i : ret - inl;
}
n-=i;
ctx->buf_off+=i;
@@ -325,10 +325,7 @@ again:
{
i=enc_write(b,NULL,0);
if (i < 0)
- {
- ret=i;
- break;
- }
+ return i;
}
if (!ctx->finished)