evp/bio_enc.c: stop using pointer arithmetic for error detection.
authorAndy Polyakov <appro@openssl.org>
Tue, 23 Aug 2016 11:31:36 +0000 (13:31 +0200)
committerMatt Caswell <matt@openssl.org>
Wed, 24 Aug 2016 09:34:27 +0000 (10:34 +0100)
Thanks to David Benjamin for reporting this.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
crypto/evp/bio_enc.c

index e3aaadb..5a3beef 100644 (file)
@@ -148,9 +148,12 @@ static int enc_read(BIO *b, char *out, int outl)
 
         if (ctx->read_start == ctx->read_end) { /* time to read more data */
             ctx->read_end = ctx->read_start = &(ctx->buf[BUF_OFFSET]);
-            ctx->read_end += BIO_read(next, ctx->read_start, ENC_BLOCK_SIZE);
+            i = BIO_read(next, ctx->read_start, ENC_BLOCK_SIZE);
+            if (i > 0)
+                ctx->read_end += i;
+        } else {
+            i = ctx->read_end - ctx->read_start;
         }
-        i = ctx->read_end - ctx->read_start;
 
         if (i <= 0) {
             /* Should be continue next time we are called? */