From a845213e71ac6f15f5b00680ba9c952e61c736b7 Mon Sep 17 00:00:00 2001 From: ianshade Date: Wed, 9 Jun 2021 10:44:16 +0200 Subject: [PATCH] fix(ffmpeg_producer): prevent loading unreadable files leads to returning 404 on LOAD, PLAY etc. if the file can't be read --- src/modules/ffmpeg/producer/ffmpeg_producer.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/modules/ffmpeg/producer/ffmpeg_producer.cpp b/src/modules/ffmpeg/producer/ffmpeg_producer.cpp index be2dc34916..580cb4c095 100644 --- a/src/modules/ffmpeg/producer/ffmpeg_producer.cpp +++ b/src/modules/ffmpeg/producer/ffmpeg_producer.cpp @@ -238,8 +238,23 @@ bool has_invalid_protocol(const std::wstring& filename) return false; } +bool is_readable(const std::wstring& filename) +{ + auto u8filename = u8(filename); + + std::ifstream file(u8filename); + if (file) { + return true; + } + return false; +} + bool is_valid_file(const std::wstring& filename) { + if (!is_readable(filename)) { + return false; + } + const auto valid_ext = has_valid_extension(filename); if (valid_ext) { return true;