From 19f8b437c38391362e6a52fdbc1e90cce8844f9d Mon Sep 17 00:00:00 2001 From: Mohamed Ali Chebbi Date: Sat, 4 Feb 2023 23:02:45 +0100 Subject: [PATCH] add test/data for video support : add enforce exceptions --- src/asfvideo.cpp | 6 ++++-- src/riffvideo.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/asfvideo.cpp b/src/asfvideo.cpp index 19d938b4..b976ee4e 100644 --- a/src/asfvideo.cpp +++ b/src/asfvideo.cpp @@ -4,6 +4,7 @@ #include #include "basicio.hpp" #include "config.h" +#include "enforce.hpp" #include "error.hpp" #include "futils.hpp" #include "helper_functions.hpp" @@ -370,8 +371,9 @@ void AsfVideo::codecList() { xmpData()[codec + std::string(".CodecDescription")] = readStringWcharTag(io_, codec_desc_length); uint16_t codec_info_length = readWORDTag(io_); - if (codec_info_length && codec_info_length + io_->tell() <= io_->size()) - xmpData()[codec + std::string(".CodecInfo")] = readStringTag(io_, codec_info_length); + Internal::enforce(codec_info_length && codec_info_length + io_->tell() < io_->size(), + Exiv2::ErrorCode::kerCorruptedMetadata); + xmpData()[codec + std::string(".CodecInfo")] = readStringTag(io_, codec_info_length); } } // AsfVideo::codecList diff --git a/src/riffvideo.cpp b/src/riffvideo.cpp index 9d953b40..0cc935c3 100644 --- a/src/riffvideo.cpp +++ b/src/riffvideo.cpp @@ -8,6 +8,7 @@ // included header files #include "riffvideo.hpp" +#include "enforce.hpp" #include "error.hpp" #include "futils.hpp" #include "helper_functions.hpp" @@ -388,10 +389,9 @@ void RiffVideo::readMetadata() { } // RiffVideo::readMetadata RiffVideo::HeaderReader::HeaderReader(BasicIo::UniquePtr& io) { - if (io->size() >= io->tell() + DWORD + DWORD) { - id_ = readStringTag(io); - size_ = readDWORDTag(io); - } + Internal::enforce(io->size() > io->tell() + DWORD + DWORD, Exiv2::ErrorCode::kerCorruptedMetadata); + id_ = readStringTag(io); + size_ = readDWORDTag(io); } bool RiffVideo::equal(const std::string& str1, const std::string& str2) {