mpatric / mp3agic

A java library for reading mp3 files and reading / manipulating the ID3 tags (ID3v1 and ID3v2.2 through ID3v2.4).
MIT License
1.2k stars 310 forks source link

Mp3File.getLengthInMilliseconds() - integer overflow #134

Closed ltuch closed 5 years ago

ltuch commented 7 years ago

I have a large mp3 file which is more than 360Mb in size.

When the getLengthInMilliseconds function is invoked on this file the result is a negative number.

This appears due to an integer overflow when calculating the difference between the endOffset and the startOffset. As the endOffset and the startOffset are integers the expression evaluates as an integer and overflows to be a negative number.

Perhaps a long should be used for the endOffset to cater for large mp3 files?