From c772d65dca0bc0aeea970b4320d4d9d7bb382708 Mon Sep 17 00:00:00 2001 From: Serial <69764315+Serial-ATA@users.noreply.github.com> Date: Fri, 21 Apr 2023 21:54:33 -0400 Subject: [PATCH] ID3v2: Fix parsing of SYLT frames --- src/id3/v2/items/sync_text.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/id3/v2/items/sync_text.rs b/src/id3/v2/items/sync_text.rs index eb4273c8..eb5fc60f 100644 --- a/src/id3/v2/items/sync_text.rs +++ b/src/id3/v2/items/sync_text.rs @@ -127,8 +127,8 @@ impl SynchronizedText { }; } - let mut pos = cursor.stream_position()? as u32; - let total = (data.len() - 6) as u32 - pos; + let mut pos = cursor.stream_position()?; + let total = (data.len() - 6) as u64 - pos; let mut content = Vec::new(); @@ -146,6 +146,8 @@ impl SynchronizedText { if let Some(raw_text) = read_to_terminator(&mut cursor, TextEncoding::UTF16) { + pos += raw_text.len() as u64; + return utf16_decode(&raw_text, endianness) .map_err(|_| Id3v2Error::new(Id3v2ErrorKind::BadSyncText).into()); } @@ -159,7 +161,7 @@ impl SynchronizedText { .unwrap_or_default()) })()?; - pos += text.len() as u32; + pos += (text.len() + 1) as u64; let time = cursor .read_u32::()