#877369 perl: Digest::MD5 64 bit issue, calculates incorrect MD5

Package:
perl
Source:
perl
Description:
Larry Wall's Practical Extraction and Report Language
Submitter:
Marc Lehmann
Date:
2021-05-17 18:54:05 UTC
Severity:
normal
#877369#5
Date:
2017-10-01 04:19:34 UTC
From:
To:
Dear Maintainer,

Digest::MD5 calculates the wrong MD5 for large scalars:

$ perl -e 'print "\x00" x 1024 x 1024 x 1024 x 9'|md5sum -
97606009c3309d3a0b4b40ae9fadc720  -

$ perl -MDigest::MD5 -E 'say Digest::MD5::md5_hex "\x00" x 1024 x 1024 x 1024 x 9'
e02694e929aec3068ff272bebe0ae0a4

This is likely due to buggy length calculation in MD5.xs, which fails for
large values of "len" (and hasn't changed for 5.26):

    ctx->bytes_low += len;
    if (ctx->bytes_low < len) /* wrap around */
        ctx->bytes_high++;

#877369#10
Date:
2017-10-03 13:56:39 UTC
From:
To:
Control: forwarded -1 https://rt.cpan.org/Ticket/Display.html?id=123185

Thanks for the bugreport, which I've forwarded to
<https://rt.cpan.org/Ticket/Display.html?id=123185>. Note that the problem
doesn't happen if you break up the input into smaller chunks using the
OO interface which might be a viable workaround.

Cheers,
Dominic.