From 6b51429203aa59d687c49200033e5edf4496a6a2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 13 Aug 2019 12:19:31 +0200 Subject: [PATCH] decoder/opus: move comment size check to ScanOneOpusTag() Prepare for parsing large binary comments (such as METADATA_BLOCK_PICTURE). --- src/decoder/plugins/OpusTags.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/decoder/plugins/OpusTags.cxx b/src/decoder/plugins/OpusTags.cxx index ce4e8f6ef..931becbd1 100644 --- a/src/decoder/plugins/OpusTags.cxx +++ b/src/decoder/plugins/OpusTags.cxx @@ -45,6 +45,10 @@ ScanOneOpusTag(StringView name, StringView value, ReplayGainInfo *rgi, TagHandler &handler) noexcept { + if (value.size >= 4096) + /* ignore large values */ + return; + if (rgi != nullptr && name.EqualsIgnoreCase("R128_TRACK_GAIN")) { /* R128_TRACK_GAIN is a Q7.8 fixed point number in dB */ @@ -97,9 +101,6 @@ ScanOpusTags(const void *data, size_t size, if (s == nullptr) return false; - if (s.size >= 4096) - continue; - const auto split = s.Split('='); if (split.first.empty() || split.second.IsNull()) continue;