summaryrefslogtreecommitdiff
path: root/src/MXF.cpp
diff options
context:
space:
mode:
authorWolfgang Ruppel <imftool@t-online.de>2019-07-06 15:56:43 +0200
committerGitHub <noreply@github.com>2019-07-06 15:56:43 +0200
commitae53f039c3bca75a60ad4c7fa8e004ab1c530a96 (patch)
treecedc054ada678485b8fdce9186b779a7c0e663e8 /src/MXF.cpp
parent0317dcb43c14eae0393552999bc2389abec52336 (diff)
parent5c74d64d6e8d72b54e4ab34204c1ba06539422f5 (diff)
Merge pull request #3 from cinecert/master
Sync with upstream
Diffstat (limited to 'src/MXF.cpp')
-rwxr-xr-xsrc/MXF.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/MXF.cpp b/src/MXF.cpp
index 743cc69..b49fb83 100755
--- a/src/MXF.cpp
+++ b/src/MXF.cpp
@@ -125,6 +125,11 @@ ASDCP::MXF::RIP::InitFromFile(const Kumu::FileReader& Reader)
if ( ASDCP_SUCCESS(result) )
{
+ if (m_ValueLength < 4)
+ {
+ DefaultLogSink().Error("RIP is too short.\n");
+ return RESULT_KLV_CODING(__LINE__, __FILE__);
+ }
Kumu::MemIOReader MemRDR(m_ValueStart, m_ValueLength - 4);
result = PairArray.Unarchive(&MemRDR) ? RESULT_OK : RESULT_KLV_CODING(__LINE__, __FILE__);
}
@@ -448,6 +453,11 @@ ASDCP::MXF::Primer::InitFromBuffer(const byte_t* p, ui32_t l)
if ( ASDCP_SUCCESS(result) )
{
+ if (m_ValueStart + m_ValueLength > p + l)
+ {
+ DefaultLogSink().Error("Primer entry too long.\n");
+ return RESULT_KLV_CODING(__LINE__, __FILE__);
+ }
Kumu::MemIOReader MemRDR(m_ValueStart, m_ValueLength);
result = LocalTagEntryBatch.Unarchive(&MemRDR) ? RESULT_OK : RESULT_KLV_CODING(__LINE__, __FILE__);
}
@@ -1380,6 +1390,12 @@ ASDCP::MXF::InterchangeObject::InitFromBuffer(const byte_t* p, ui32_t l)
if ( ASDCP_SUCCESS(result) )
{
+ if ( ( m_ValueStart + m_ValueLength ) > ( p + l ) )
+ {
+ DefaultLogSink().Error("Interchange Object value extends past buffer length.\n");
+ return RESULT_KLV_CODING(__LINE__, __FILE__);
+ }
+
TLVReader MemRDR(m_ValueStart, m_ValueLength, m_Lookup);
result = InitFromTLVSet(MemRDR);
}
@@ -1440,9 +1456,24 @@ ASDCP::MXF::InterchangeObject::IsA(const byte_t* label)
//------------------------------------------------------------------------------------------
+struct FactoryCompareUL
+{
+ bool operator()(const ASDCP::UL& lhs, const ASDCP::UL& rhs) const
+ {
+ ui32_t test_size = lhs.Size() < rhs.Size() ? lhs.Size() : rhs.Size();
+ for (ui32_t i = 0; i < test_size; i++)
+ {
+ if (i == 7) continue; // skip version to be symmetrical with UL::operator==
+ if (lhs.Value()[i] != rhs.Value()[i])
+ return lhs.Value()[i] < rhs.Value()[i];
+ }
+
+ return false;
+ }
+};
-typedef std::map<ASDCP::UL, ASDCP::MXF::MXFObjectFactory_t>FactoryMap_t;
+typedef std::map<ASDCP::UL, ASDCP::MXF::MXFObjectFactory_t, FactoryCompareUL>FactoryMap_t;
typedef FactoryMap_t::iterator FLi_t;
//
@@ -1503,7 +1534,7 @@ ASDCP::MXF::CreateObject(const Dictionary*& Dict, const UL& label)
}
}
- FLi_t i = s_FactoryList.find(label.Value());
+ FLi_t i = s_FactoryList.find(label);
if ( i == s_FactoryList.end() )
return new InterchangeObject(Dict);