Skip to content

ID3v1: Don't mistake the end of an APE tag for an ID3v1 tag - #763

Merged
Serial-ATA merged 2 commits into
Serial-ATA:mainfrom
ikskoder:id3v1-ape-footer
Nov 23, 2026
Merged

Serial-ATA merged 2 commits into
Serial-ATA:mainfrom
ikskoder:id3v1-ape-footer

Conversation

@ikskoder

Copy link
Copy Markdown
Contributor

closes #762

find_id3v1 now checks the last 32 bytes of the stream before it accepts a TAG marker. If they start with APETAGEX, the stream ends with an APE tag footer, nothing can follow it, and there is no ID3v1 tag.

Every reader and writer that looks for an ID3v1 tag goes through find_id3v1, so this one check covers reading, saving and TagType::Id3v1.remove_from.

The test is the reproducer from the issue: an MP3 whose only tag is a 131 byte APE tag. It reads the file, saves an ID3v2 tag into it, and removes the ID3v1 tag it does not have, checking the APE tag after each step. It fails on main without the fix. The changelog entry is under Unreleased, Fixed.

ikskoder and others added 2 commits November 22, 2026 19:45
`find_id3v1` took any "TAG" 128 bytes from the end of the stream as an ID3v1 tag. When the stream ends with an APE tag, those bytes can belong to it, such as the "TAG" in the "APETAGEX" preamble of a 131 byte tag's header. The APE tag was then not found, and any write replaced its last 128 bytes with the bogus ID3v1 tag.

If a stream ends with an APE tag footer, nothing follows the APE tag, so the stream has no ID3v1 tag.

closes Serial-ATA#762
@Serial-ATA Serial-ATA added this to the 0.26.0 milestone Nov 23, 2026
@Serial-ATA
Serial-ATA merged commit 700bf53 into Serial-ATA:main Nov 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MPEG: An APE tag ending the file is read as ID3v1 when "TAG" lands 128 bytes from the end, and saving overwrites it

2 participants