From 3391bd80c423a024cd19af7db68bbc3f41dccbd9 Mon Sep 17 00:00:00 2001 From: bobsayshilol Date: Sat, 24 Apr 2021 15:56:52 +0100 Subject: [PATCH] FLAC: Validate the size of a read Without this we can crash trying to dereference parts of `header`. --- taglib/flac/flacfile.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/taglib/flac/flacfile.cpp b/taglib/flac/flacfile.cpp index ada215db..6ecd3bad 100644 --- a/taglib/flac/flacfile.cpp +++ b/taglib/flac/flacfile.cpp @@ -497,6 +497,11 @@ void FLAC::File::scan() seek(nextBlockOffset); const ByteVector header = readBlock(4); + if(header.size() != 4) { + debug("FLAC::File::scan() -- Failed to read a block header"); + setValid(false); + return; + } // Header format (from spec): // <1> Last-metadata-block flag