From 5dd5e301b3a17920c22c69f7afbf7e2b5d2207be Mon Sep 17 00:00:00 2001 From: Martchus Date: Fri, 12 Aug 2022 00:02:38 +0200 Subject: [PATCH] Fix adding ID3v2 tag to file with unknown container format The bytes skipped while searching for MP3 frames should not be used as container offset. The container offset should just the offset after the first ID3v2 tag (or zero if there are no tags). --- mediafileinfo.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mediafileinfo.cpp b/mediafileinfo.cpp index 3f3e983..0e10319 100644 --- a/mediafileinfo.cpp +++ b/mediafileinfo.cpp @@ -148,6 +148,7 @@ void MediaFileInfo::parseContainerFormat(Diagnostics &diag, AbortableProgressFee m_paddingSize = 0; m_containerOffset = 0; std::size_t bytesSkippedBeforeContainer = 0; + std::streamoff id3v2Size = 0; // read signatrue char buff[16]; @@ -178,6 +179,7 @@ startParsingSignature: if ((bytesSkippedBeforeContainer += bytesSkipped) >= 0x800u) { m_containerParsingStatus = ParsingStatus::NotSupported; m_containerFormat = ContainerFormat::Unknown; + m_containerOffset = id3v2Size; return; } @@ -204,6 +206,7 @@ startParsingSignature: // footer present m_containerOffset += 10; } + id3v2Size = m_containerOffset; // continue reading signature goto startParsingSignature;