Skip to content

Commit

Permalink
fix(ffmpeg_producer): prevent loading unreadable files
Browse files Browse the repository at this point in the history
leads to returning 404 on LOAD, PLAY etc. if the file can't be read
  • Loading branch information
ianshade committed Jun 9, 2021
1 parent fd75dd5 commit a845213
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/modules/ffmpeg/producer/ffmpeg_producer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a845213

Please sign in to comment.