Avoid overflow in MDC2_Update()
[openssl.git] / 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;