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 6397a47..37d99f4 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;