aadsm / jsmediatags

Media Tags Reader (ID3, MP4, FLAC)
Other
748 stars 128 forks source link

Chrome crashes with MP3 file #78

Closed mattbasta closed 6 years ago

mattbasta commented 6 years ago

I've encountered a malformed MP3 file that, when read by jsmediatags in Chrome, causes the current tab to crash. I've been able to reproduce this reliably.

Here's a screenshot of a hex dump of the beginning of the file: screen shot 2017-10-05 at 10 15 17 pm

There is maybe five to ten seconds between when the file is passed (as an ArrayBuffer, I believe) and when the tab crashes. Pausing the debugger in that time shows it hammering most of the file. In this case, the file is ~25MB.

screen shot 2017-10-05 at 10 20 01 pm

When readFrames on ID3v2FrameReader, it's passed an offset of 26 and an offset end of 176. The size of the ID3 tags is 166 bytes. As it reads the frames, it encounters what I assume to be junk, since it loops off into the non-ID3 chunks of the file.

I can provide a copy of the file if needed. Let me know if it would be helpful.

Perhaps a good, straightforward solution would be to throw an error if the frame data offset plus the frame data size is greater than the size of the ID3 section?

aadsm commented 6 years ago

This looks interesting, if you could provide the file that would be great. Thanks for reporting it.

mattbasta commented 6 years ago

Thanks! I emailed you a link to the file.

aadsm commented 6 years ago

I found the issue with this file. The code currently doesn’t support parsing extended headers in the 2.4.0 format. I should ship a fix soon for this.