From 27057e5baca5b23b3105fa139f9f147054754ff0 Mon Sep 17 00:00:00 2001 From: Alex <69764315+Serial-ATA@users.noreply.github.com> Date: Wed, 29 Dec 2021 22:26:36 -0500 Subject: [PATCH 1/2] Fix FLAC max size --- src/ogg/flac/write.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ogg/flac/write.rs b/src/ogg/flac/write.rs index b6316caa..4ae5f558 100644 --- a/src/ogg/flac/write.rs +++ b/src/ogg/flac/write.rs @@ -10,6 +10,8 @@ use std::io::{Cursor, Read, Seek, SeekFrom, Write}; use byteorder::{LittleEndian, WriteBytesExt}; +const MAX_BLOCK_SIZE: u32 = 16777215; + pub(in crate) fn write_to(data: &mut File, tag: &mut VorbisCommentsRef) -> Result<()> { let stream_info = verify_flac(data)?; let stream_info_end = stream_info.end as usize; @@ -127,7 +129,7 @@ fn create_comment_block( let len = (writer.get_ref().len() - 1) as u32; - if len > 65535 { + if len > MAX_BLOCK_SIZE { return Err(LoftyError::TooMuchData); } @@ -158,7 +160,7 @@ fn create_picture_blocks( let pic_bytes = pic.as_flac_bytes(info, false); let pic_len = pic_bytes.len() as u32; - if pic_len > 65535 { + if pic_len > MAX_BLOCK_SIZE { return Err(LoftyError::TooMuchData); } From 5808d44aa98ff0268ddcabb0ee4c91a93ecf5521 Mon Sep 17 00:00:00 2001 From: Alex <69764315+Serial-ATA@users.noreply.github.com> Date: Wed, 29 Dec 2021 22:31:03 -0500 Subject: [PATCH 2/2] Clippy --- src/ogg/flac/write.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ogg/flac/write.rs b/src/ogg/flac/write.rs index 4ae5f558..440dcf21 100644 --- a/src/ogg/flac/write.rs +++ b/src/ogg/flac/write.rs @@ -10,7 +10,7 @@ use std::io::{Cursor, Read, Seek, SeekFrom, Write}; use byteorder::{LittleEndian, WriteBytesExt}; -const MAX_BLOCK_SIZE: u32 = 16777215; +const MAX_BLOCK_SIZE: u32 = 16_777_215; pub(in crate) fn write_to(data: &mut File, tag: &mut VorbisCommentsRef) -> Result<()> { let stream_info = verify_flac(data)?;