oiiodecoder: fixed segfault caused by some OIIO decoders if they received

unexpected data

When "probing" footage, Olive runs it past all of its decoders until one
responds that it can decode this file. However this caused issues when some
OIIO decoders would erroneously pick up incompatible files, try to read them
and segfault the entire app (notable OpenJPEG with MPEG-4 and RLA with WAVE
audio). We now use the file extension to check with OIIO if it "should" be
compatible before actually testing if it is.

This is not a "perfect" solution (i.e. someone could recreate the segfault by
renaming an MPEG-4 file to an image extension like .JPG), but is probably as
much as can be done Olive-side and should filter out all segfaults under normal
circumstances.
This commit is contained in:
itsmattkc
2020-01-26 11:54:49 +11:00
parent 6bef94b3e2
commit 490a634473
2 changed files with 21 additions and 0 deletions
+19
View File
@@ -21,9 +21,12 @@
#include "oiiodecoder.h"
#include <QDebug>
#include <QFileInfo>
#include "common/define.h"
QStringList OIIODecoder::supported_formats_;
OIIODecoder::OIIODecoder() :
image_(nullptr),
frame_(nullptr)
@@ -37,6 +40,22 @@ QString OIIODecoder::id()
bool OIIODecoder::Probe(Footage *f)
{
// We prioritize OIIO over FFmpeg to pick up still images more effectively, but some OIIO decoders (notably OpenJPEG)
// will segfault entirely if given unexpected data (an MPEG-4 for instance). To workaround this issue, we use OIIO's
// "extension_list" attribute and match it with the extension of the file.
// Check if we've created the supported formats list, create it if not
if (supported_formats_.isEmpty()) {
supported_formats_ = QString::fromStdString(OIIO::get_string_attribute("extension_list")).split(';');
}
//
QFileInfo file_info(f->filename());
if (!supported_formats_.contains(file_info.completeSuffix())) {
return false;
}
std::string std_filename = f->filename().toStdString();
auto in = OIIO::ImageInput::open(std_filename);