int n = fp.read(temp, 0, (int)Math.min(temp.length, (int)size-total));
which reads data into a temp byte array before passing it to a MessageDigest. It all works hunky dory for small files but for files at around the 2 GB mark an IndexOutOfBoundsException exception is thrown.
I believe the problem is that size of the file (on line 339 above) is being downcast to an intbeforetotal is subtracted. This means that for files larger than 2^31 ~> 2 GB, dodgy values for len are being passed to RandomAccessFile.read().
So the fix should be to just change line 339 to the following - note the brackets around (size-total):
int n = fp.read(temp, 0, (int)Math.min(temp.length, (int)(size-total)));
Then it is the result of the calculation which is downcast to an int.
matthewThu 27 Feb 2020
Ticket promoted to #2784 and assigned to matthew
Hi SlimerDude - I have reproduced this bug and will push a fix shortly.
SlimerDude Wed 26 Feb 2020
Calculating an MD5 digest for large files causes this error to be thrown:
The offending line is this one:
which reads data into a
temp
byte array before passing it to aMessageDigest
. It all works hunky dory for small files but for files at around the 2 GB mark anIndexOutOfBoundsException
exception is thrown.I believe the problem is that
size
of the file (on line 339 above) is being downcast to anint
beforetotal
is subtracted. This means that for files larger than2^31 ~> 2 GB
, dodgy values forlen
are being passed to RandomAccessFile.read().So the fix should be to just change line 339 to the following - note the brackets around
(size-total)
:Then it is the result of the calculation which is downcast to an
int
.matthew Thu 27 Feb 2020
Ticket promoted to #2784 and assigned to matthew
Hi SlimerDude - I have reproduced this bug and will push a fix shortly.
matthew Thu 27 Feb 2020
Ticket resolved in 1.0.74