Set error if EVP_CipherUpdate fails.
authorDr. Stephen Henson <steve@openssl.org>
Tue, 26 Jul 2016 15:51:49 +0000 (16:51 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Tue, 26 Jul 2016 16:12:46 +0000 (17:12 +0100)
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit ee6ce5cc368574c0b0b470e61ee2f82a0efadbb7)

Conflicts:
crypto/evp/bio_enc.c

crypto/evp/bio_enc.c

index 363e0246aedc91ca85eabf247be219ea680fedb5..590f236e8f117dd8bd313e4f9a5f77213c72a6e6 100644 (file)
@@ -201,9 +201,14 @@ static int enc_read(BIO *b, char *out, int outl)
                 break;
             }
         } else {
-            EVP_CipherUpdate(&(ctx->cipher),
-                             (unsigned char *)ctx->buf, &ctx->buf_len,
-                             (unsigned char *)&(ctx->buf[BUF_OFFSET]), i);
+            if (!EVP_CipherUpdate(&ctx->cipher,
+                                  (unsigned char *)ctx->buf, &ctx->buf_len,
+                                  (unsigned char *)&(ctx->buf[BUF_OFFSET]),
+                                  i)) {
+                BIO_clear_retry_flags(b);
+                ctx->ok = 0;
+                return 0;
+            }
             ctx->cont = 1;
             /*
              * Note: it is possible for EVP_CipherUpdate to decrypt zero