From b14438d3e1a98a9034dc43ce40936af762e039b7 Mon Sep 17 00:00:00 2001
From: Geoff Thorpe <geoff@openssl.org>
Date: Sun, 4 May 2014 18:44:14 -0400
Subject: [PATCH] evp: prevent underflow in base64 decoding

This is an attempt to resolve RT #2608.

Signed-off-by: Geoff Thorpe <geoff@openssl.org>
---
 crypto/evp/encode.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/crypto/evp/encode.c b/crypto/evp/encode.c
index e278a1b..a4f7674 100644
--- a/crypto/evp/encode.c
+++ b/crypto/evp/encode.c
@@ -324,6 +324,7 @@ int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
 				v=EVP_DecodeBlock(out,d,n);
 				n=0;
 				if (v < 0) { rv=0; goto end; }
+				if (eof > v) { rv=-1; goto end; }
 				ret+=(v-eof);
 				}
 			else
-- 
1.9.1

