477d4a1
diff -up openssl-1.0.1e/crypto/evp/bio_enc.c.enc-fail openssl-1.0.1e/crypto/evp/bio_enc.c
477d4a1
--- openssl-1.0.1e/crypto/evp/bio_enc.c.enc-fail	2013-02-11 16:26:04.000000000 +0100
477d4a1
+++ openssl-1.0.1e/crypto/evp/bio_enc.c	2014-03-04 15:21:12.185821738 +0100
477d4a1
@@ -198,10 +198,15 @@ static int enc_read(BIO *b, char *out, i
477d4a1
 			}
477d4a1
 		else
477d4a1
 			{
477d4a1
-			EVP_CipherUpdate(&(ctx->cipher),
477d4a1
+			if (!EVP_CipherUpdate(&(ctx->cipher),
477d4a1
 				(unsigned char *)ctx->buf,&ctx->buf_len,
477d4a1
-				(unsigned char *)&(ctx->buf[BUF_OFFSET]),i);
477d4a1
-			ctx->cont=1;
477d4a1
+				(unsigned char *)&(ctx->buf[BUF_OFFSET]),i))
477d4a1
+				{
477d4a1
+				ctx->ok = 0;
477d4a1
+				ctx->cont = 0;
477d4a1
+				}
477d4a1
+			else
477d4a1
+				ctx->cont=1;
477d4a1
 			/* Note: it is possible for EVP_CipherUpdate to
477d4a1
 			 * decrypt zero bytes because this is or looks like
477d4a1
 			 * the final block: if this happens we should retry
477d4a1
@@ -257,9 +262,14 @@ static int enc_write(BIO *b, const char
477d4a1
 	while (inl > 0)
477d4a1
 		{
477d4a1
 		n=(inl > ENC_BLOCK_SIZE)?ENC_BLOCK_SIZE:inl;
477d4a1
-		EVP_CipherUpdate(&(ctx->cipher),
477d4a1
+		if (!EVP_CipherUpdate(&(ctx->cipher),
477d4a1
 			(unsigned char *)ctx->buf,&ctx->buf_len,
477d4a1
-			(unsigned char *)in,n);
477d4a1
+			(unsigned char *)in,n))
477d4a1
+			{
477d4a1
+			BIO_copy_next_retry(b);
477d4a1
+			ctx->ok = 0;
477d4a1
+			return ret - inl;
477d4a1
+			}
477d4a1
 		inl-=n;
477d4a1
 		in+=n;
477d4a1