Skip to content

Saving specific tag corrupts tag (SizeMismatch) #469

@probablykasper

Description

@probablykasper

Reproducer

use lofty::config::WriteOptions;
use lofty::file::TaggedFileExt;
use lofty::read_from_path;
use lofty::tag::{Accessor, TagExt};

fn main() {
	let bugged_song_path = "bugged.opus";
	std::fs::copy("song.opus", bugged_song_path).unwrap();

	let mut tagged_file = read_from_path(bugged_song_path).unwrap();
	let tag = tagged_file.primary_tag_mut().unwrap();

	tag.set_artist("Kuraine".to_owned());

	tag.save_to_path(bugged_song_path, WriteOptions::default())
		.unwrap();

	// Open again
	match read_from_path(bugged_song_path) {
		Ok(_) => {}
		Err(e) => println!("{:?}", e),
	};
}

Summary

Saving this specific combination of metadata corrupts the tag. Opening the corrupted file's tag gives a SizeMismatch error

Assets

song.opus.zip

Corrupt file created by reproducer:
bugged.opus.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions