Menu

#130 Hangs CPU on corrupted mp3 file

open
5
2009-05-23
2009-05-23
No

Hey there !
First of all, thanks for such nice project, I'm using entagged at my final degree project and it works great !
Except that i found entagged hanging CPU at corrupted mp3 files. My test file hasn't any metadata frames (blank spaces, and some part of the file has music). Entagged hands cpu util it reads every single byte of this corrupted file.

It hangs at:
entagged.audioformats.mp3.util.Mp3InfoReader.java @ function read(RandomAccessFile raf):
while ( !( (b[0]&0xFF)==0xFF && (b[1]&0xE0)==0xE0 && (b[1]&0x06)!=0 && (b[2]&0xF0)!=0xF0 && (b[2]&0x0C)!=0x0C ) && raf.getFilePointer() < raf.length()-4) {
raf.seek( raf.getFilePointer() - 3);
raf.read(b);
}

As this file has blank metadata frames, i decided to change the code line 52:

if (ID3.equals("ID3")) {
raf.seek(6);
id3TagSize = read_syncsafe_integer(raf);
raf.seek(id3TagSize+10);
} else {
throw new CannotReadException("ID3 beggining of the file not found");
}

Hope it helps!

Discussion


Log in to post a comment.