Note cipher BIO write errors too.
authorDr. Stephen Henson <steve@openssl.org>
Tue, 26 Jul 2016 19:22:49 +0000 (20:22 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Tue, 26 Jul 2016 21:45:04 +0000 (22:45 +0100)
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 976ef6adcc157233fb641ca99e2424630ef1814f)

Conflicts:
crypto/evp/bio_enc.c

crypto/evp/bio_enc.c

index 590f236e8f117dd8bd313e4f9a5f77213c72a6e6..0806f233b67d0c5b5834ccdf01db757a3e0ab28a 100644 (file)
@@ -265,9 +265,13 @@ static int enc_write(BIO *b, const char *in, int inl)
     ctx->buf_off = 0;
     while (inl > 0) {
         n = (inl > ENC_BLOCK_SIZE) ? ENC_BLOCK_SIZE : inl;
-        EVP_CipherUpdate(&(ctx->cipher),
-                         (unsigned char *)ctx->buf, &ctx->buf_len,
-                         (unsigned char *)in, n);
+        if (!EVP_CipherUpdate(&ctx->cipher,
+                              (unsigned char *)ctx->buf, &ctx->buf_len,
+                              (unsigned char *)in, n)) {
+            BIO_clear_retry_flags(b);
+            ctx->ok = 0;
+            return 0;
+        }
         inl -= n;
         in += n;