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

Dominic Hargreaves dom at earth.li
Tue Oct 3 13:56:39 UTC 2017


Control: forwarded -1 https://rt.cpan.org/Ticket/Display.html?id=123185

On Sun, Oct 01, 2017 at 06:19:34AM +0200, Marc Lehmann wrote:
> Package: perl
> Version: 5.24.1-3+deb9u2
> Severity: normal
> 
> 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++;

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.




More information about the Perl-maintainers mailing list