Add heartbeat extension bounds check.
[openssl.git] / crypto / mdc2 / mdc2_one.c
index 6cd141b4d621b64bd9d062280fde4e7061e71dbb..72647f67ede4ee05b5b11d261b22587f7ad296e7 100644 (file)
 #include "cryptlib.h"
 #include <openssl/mdc2.h>
 
-unsigned char *MDC2(const unsigned char *d, unsigned long n, unsigned char *md)
+unsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md)
        {
        MDC2_CTX c;
        static unsigned char m[MDC2_DIGEST_LENGTH];
 
        if (md == NULL) md=m;
-       MDC2_Init(&c);
+       if (!MDC2_Init(&c))
+               return NULL;
        MDC2_Update(&c,d,n);
         MDC2_Final(md,&c);
-       memset(&c,0,sizeof(c)); /* security consideration */
+       OPENSSL_cleanse(&c,sizeof(c)); /* security consideration */
        return(md);
        }