Don't use assertions to check application-provided arguments;
authorBodo Möller <bodo@openssl.org>
Thu, 14 Aug 2008 21:37:20 +0000 (21:37 +0000)
committerBodo Möller <bodo@openssl.org>
Thu, 14 Aug 2008 21:37:20 +0000 (21:37 +0000)
and don't unnecessarily fail on input size 0.

crypto/evp/evp_enc.c

index a1904993bf768ee37242eab523022e7aee451925..6e582c458de55b5fc7b230d3d3c546fc42cbbb43 100644 (file)
@@ -279,7 +279,12 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
        {
        int i,j,bl;
 
-       OPENSSL_assert(inl > 0);
+       if (inl <= 0)
+               {
+               *outl = 0;
+               return inl == 0;
+               }
+
        if(ctx->buf_len == 0 && (inl&(ctx->block_mask)) == 0)
                {
                if(ctx->cipher->do_cipher(ctx,out,in,inl))
@@ -381,10 +386,10 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
        int fix_len;
        unsigned int b;
 
-       if (inl == 0)
+       if (inl <= 0)
                {
-               *outl=0;
-               return 1;
+               *outl = 0;
+               return inl == 0;
                }
 
        if (ctx->flags & EVP_CIPH_NO_PADDING)