Skip to content

Commit

Permalink
Fix ID3v2 decoding, avoid infinite loop
Browse files Browse the repository at this point in the history
The ID3 reader was incorrectly skipping extended headers and was
cutting off the last 10 bytes of the last ID3 entry. Correct per
http://id3.org specs.

Fixes earlephilhower#41
  • Loading branch information
earlephilhower committed Feb 15, 2018
1 parent 54498a2 commit 01d9dae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/AudioFileSourceID3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ uint32_t AudioFileSourceID3::read(void *data, uint32_t len)
id3Size = id3Size << 7;
id3Size |= buff[9];
// Every read from now may be unsync'd
AudioFileSourceUnsync id3(src, id3Size-10, unsync);
AudioFileSourceUnsync id3(src, id3Size, unsync);

if (exthdr) {
int ehsz = (id3.getByte()<<24) | (id3.getByte()<<16) | (id3.getByte()<<8) | (id3.getByte());
for (int j=0; j<ehsz; j++) id3.getByte(); // Throw it away
for (int j=0; j<ehsz-4; j++) id3.getByte(); // Throw it away
}

do {
Expand Down

0 comments on commit 01d9dae

Please sign in to comment.