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
AIFF save panic: out-of-range slice in Vec when rewriting text chunks (range end index ... out of range) #619
use lofty::config::{ParseOptions,ParsingMode,WriteOptions};use lofty::file::AudioFile;use lofty::iff::aiff::AiffFile;use lofty::probe::Probe;fnmain(){// Put the problematic AIFF next to this Cargo.toml, or pass path as arg.let arg_path = std::env::args().nth(1);let source = arg_path.unwrap_or_else(|| "..\\Kobosil - Bei Nacht H (178).aiff".to_string());let source_path = std::path::PathBuf::from(&source);if !source_path.exists(){eprintln!("file not found: {}", source_path.display());
std::process::exit(2);}// Work on temp copy.let temp = std::env::temp_dir().join("lofty_aiff_panic_repro.aiff");
std::fs::copy(&source_path,&temp).expect("copy failed");letmut file = std::fs::File::options().read(true).write(true).open(&temp).expect("open failed");let parse_options = ParseOptions::new().parsing_mode(ParsingMode::BestAttempt).read_cover_art(true).implicit_conversions(false);let probe = Probe::new(&mut file).options(parse_options).guess_file_type().expect("probe failed");letmut aiff = AiffFile::read_from(probe.into_inner(), parse_options).expect("AIFF read failed");letmut text = aiff.text_chunks().cloned().unwrap_or_default();
text.name = Some("UAT_DIRECT_LOFTY_TITLE".to_string());
aiff.set_text_chunks(text);// Panic is observed here for the problematic sample.
aiff.save_to(&mut file,WriteOptions::default()).expect("save failed");println!("save succeeded: {}", temp.display());}
Summary
Command:
cargo run -q -p uat_cli --bin lofty_aiff_direct_repro -- "D:\Music\ΝEW\ΜDBU\yshar38\TECHNO\Kobosil - Bei Nacht H (178).aiff"
Observed panic:
thread 'main' panicked at ...\alloc\src\vec\mod.rs:2852:36:
range end index 81507680 out of range for slice of length 81507679
changed the title [-]IFF save panic: out-of-range slice in Vec when rewriting text chunks (range end index ... out of range)[/-][+]AIFF save panic: out-of-range slice in Vec when rewriting text chunks (range end index ... out of range)[/+]on Feb 22, 2026
Activity
Serial-ATA commentedon Feb 19, 2026
Interesting, the ID3v2 chunk has padding but it's included in the chunk size which isn't valid per the spec (https://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/AIFF/Docs/AIFF-1.3.pdf):
Right now, it's assumed that the padding is correct so we just blindly try to skip it, but end up going outside of the bounds of the file data:
lofty-rs/lofty/src/id3/v2/write/chunk_file.rs
Lines 62 to 65 in c01dc7b
I'll try to come up with some hack to detect this.
[-]IFF save panic: out-of-range slice in Vec when rewriting text chunks (range end index ... out of range)[/-][+]AIFF save panic: out-of-range slice in Vec when rewriting text chunks (range end index ... out of range)[/+]