mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-11-10 06:34:18 +00:00
FLAC: Stop moving padding blocks
`PADDING` blocks were incorrectly getting moved to the end of the header without the `Last-metadata-block` getting set.
This commit is contained in:
parent
0b903e9698
commit
03047bb345
2 changed files with 13 additions and 3 deletions
|
@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- This behavior already exists for OGG formats.
|
||||
|
||||
### Fixed
|
||||
- **FLAC**: Stop writing invalid `PADDING` blocks ([issue](https://github.com/Serial-ATA/lofty-rs/issues/442)) ([PR](https://github.com/Serial-ATA/lofty-rs/pull/446))
|
||||
- If a `PADDING` block existed in the original file, and it wasn't placed at the end of the header, it would
|
||||
moved without setting the `Last-metadata-block` flag. This would cause decoders to believe that the file was missing
|
||||
- **Fuzzing** (Thanks [@qarmin](https://github.com/qarmin)!) ([PR](https://github.com/Serial-ATA/lofty-rs/pull/444)):
|
||||
- **MusePack**: Fix panic when tag sizes exceed the stream length ([issue](https://github.com/Serial-ATA/lofty-rs/issues/440))
|
||||
- **AAC**: Fix panic when tag sizes exceed the stream length ([issue](https://github.com/Serial-ATA/lofty-rs/issues/439))
|
||||
|
|
|
@ -61,7 +61,8 @@ where
|
|||
|
||||
let mut cursor = Cursor::new(file_bytes);
|
||||
|
||||
let mut padding = false;
|
||||
// TODO: We need to actually use padding (https://github.com/Serial-ATA/lofty-rs/issues/445)
|
||||
let mut end_padding_exists = false;
|
||||
let mut last_block_info = (
|
||||
stream_info.byte,
|
||||
stream_info.start as usize,
|
||||
|
@ -103,14 +104,20 @@ where
|
|||
tag.vendor = Cow::Owned(vendor_str);
|
||||
},
|
||||
BLOCK_ID_PICTURE => blocks_to_remove.push((start, end)),
|
||||
BLOCK_ID_PADDING => padding = true,
|
||||
BLOCK_ID_PADDING => {
|
||||
if last_block {
|
||||
end_padding_exists = true
|
||||
} else {
|
||||
blocks_to_remove.push((start, end))
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
||||
let mut file_bytes = cursor.into_inner();
|
||||
|
||||
if !padding {
|
||||
if !end_padding_exists {
|
||||
if let Some(preferred_padding) = write_options.preferred_padding {
|
||||
log::warn!("File is missing a PADDING block. Adding one");
|
||||
|
||||
|
|
Loading…
Reference in a new issue