Avoid overflow in MDC2_Update()
authorDr. Stephen Henson <steve@openssl.org>
Fri, 19 Aug 2016 22:28:29 +0000 (23:28 +0100)
committerMatt Caswell <matt@openssl.org>
Wed, 24 Aug 2016 13:12:51 +0000 (14:12 +0100)
Thanks to Shi Lei for reporting this issue.

CVE-2016-6303

Reviewed-by: Matt Caswell <matt@openssl.org>
crypto/mdc2/mdc2dgst.c

index 6397a47e92dc22d08eda4f556019d1f2e816cc55..37d99f48a5ebcae9f5e16b52ab73e2ed3c24fae2 100644 (file)
@@ -42,7 +42,7 @@ int MDC2_Update(MDC2_CTX *c, const unsigned char *in, size_t len)
 
     i = c->num;
     if (i != 0) {
-        if (i + len < MDC2_BLOCK) {
+        if (len < MDC2_BLOCK - i) {
             /* partial block */
             memcpy(&(c->data[i]), in, len);
             c->num += (int)len;