You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ID3v2: Corruption when encountering incomplete tags #721
Originally posted by incompl September 17, 2026
Hi! I’m trying to understand whether this is intended behavior or a bug in Lofty’s ID3v2 write path.
I have an otherwise ordinary, untagged MP3 which begins directly with an MPEG frame. Its audio payload happens to contain the literal bytes ID3, followed by an invalid ID3v2 major version (0xBF), several MiB into the file.
to support MP3s with unusually large leading junk / stacked ID3v2 tags.
On saving a new ID3v2 tag, I believe this happens:
find_id3v2 searches the allowed junk window and finds the literal ID3 inside MPEG audio.
Parsing the candidate header fails, as expected, because 0xBF is not a valid ID3v2 version.
The function seeks back 10 bytes, which appears to leave the reader at the false candidate rather than at its original position.
The ID3v2 writer reads from that position to EOF, prepends the new tag, and rewrites the file.
The save reports success, but all bytes before the accidental ID3 sequence are lost.
My expectation would be that a failed candidate parse either:
restores the reader to its original position, or
continues searching for a valid header,
and that a raw ID3 sequence after the first MPEG frame is never treated as a leading tag candidate.
Is that expectation correct? If so, I can provide a bug with a regression test.
Activity
incompl commentedon Sep 19, 2026
Confirmed in my app, thanks for the quick fix!