Skip to content

ID3v2: Growing a trailing WAV or AIFF chunk decreases the container size #724

Closed

Description

@floydnant

Reproducer

Start with a RIFF/WAVE or FORM/AIFF stream whose final chunk is an ID3v2 tag, then save a larger ID3v2 tag to the same stream. After the write, compare the 32-bit container size at bytes 4 through 7 with the actual stream length minus eight.

This affects Lofty 0.25.2, 0.25.3, and the current main branch.

Summary

The trailing-chunk fast path subtracts tag growth from updated_stream_len:

updated_stream_len -= tag_chunk_size - existing_tag_len;

When the replacement is larger, the outer RIFF/FORM size becomes smaller than the file. A sufficiently large increase also underflows and panics in debug builds after the new tag bytes have been written.

Release Maestro found this while testing repeated WAV and AIFF metadata growth: floydnant/release-maestro#166

Expected behavior

Growing a trailing ID3v2 chunk should increase the outer RIFF/FORM stream length. The declared container size should equal the actual stream length minus eight after the write.

Assets

No external asset is required. The bug reproduces with a minimal in-memory RIFF or FORM header and two successive ID3v2 writes.

Activity

  1. modified the milestones: 0.25.3, 0.25.4 on Sep 19, 2026
  2. added
    bug
    on Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions