Sanity check EVP_EncodeUpdate buffer len
authorMatt Caswell <matt@openssl.org>
Mon, 27 Apr 2015 10:13:56 +0000 (11:13 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 30 Apr 2015 22:21:53 +0000 (23:21 +0100)
There was already a sanity check to ensure the passed buffer length is not
zero. Extend this to ensure that it also not negative. Thanks to Kevin
Wojtysiak (Int3 Solutions) and Paramjot Oberoi (Int3 Solutions) for
reporting this issue.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit b86d7dca69f5c80abd60896c8ed3039fc56210cc)

crypto/evp/encode.c

index 53cc5863968152e1f10a0d7d0837ac7a84d4c863..c361d1f0126994d8d4f84cae08d3083cfed0910d 100644 (file)
@@ -137,7 +137,7 @@ void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
     unsigned int total = 0;
 
     *outl = 0;
-    if (inl == 0)
+    if (inl <= 0)
         return;
     OPENSSL_assert(ctx->length <= (int)sizeof(ctx->enc_data));
     if ((ctx->num + inl) < ctx->length) {