summaryrefslogtreecommitdiff
path: root/src
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
parent0317dcb43c14eae0393552999bc2389abec52336 (diff)
parent5c74d64d6e8d72b54e4ab34204c1ba06539422f5 (diff)
Merge pull request #3 from cinecert/master
Sync with upstream
Diffstat (limited to 'src')
-rw-r--r--src/AS_02_ISXD.cpp2
-rwxr-xr-xsrc/AS_DCP_internal.h26
-rw-r--r--src/KM_fileio.cpp4
-rwxr-xr-xsrc/KM_log.cpp3
-rwxr-xr-xsrc/MXF.cpp35
-rw-r--r--src/h__02_Reader.cpp9
-rwxr-xr-xsrc/h__Reader.cpp2
7 files changed, 61 insertions, 20 deletions
diff --git a/src/AS_02_ISXD.cpp b/src/AS_02_ISXD.cpp
index f4e29c0..6230c58 100644
--- a/src/AS_02_ISXD.cpp
+++ b/src/AS_02_ISXD.cpp
@@ -319,7 +319,7 @@ AS_02::ISXD::MXFWriter::h__Writer::OpenWrite(const std::string& filename, const
return result;
}
-// Automatically sets the MXF file's metadata from the first jpeg codestream stream.
+// Automatically sets the MXF file's metadata from the first ISXD data fragment stream.
Result_t
AS_02::ISXD::MXFWriter::h__Writer::SetSourceStream(const std::string& label, const ASDCP::Rational& edit_rate)
{
diff --git a/src/AS_DCP_internal.h b/src/AS_DCP_internal.h
index 83272c0..57ed006 100755
--- a/src/AS_DCP_internal.h
+++ b/src/AS_DCP_internal.h
@@ -414,17 +414,23 @@ namespace ASDCP
// Count the sequence length in because this is the sequence
// value needed to complete the HMAC.
ASDCP::MXF::RIP::const_pair_iterator i;
- for ( i = m_RIP.PairArray.begin(); i != m_RIP.PairArray.end(); ++i, ++sequence )
+ for ( i = m_RIP.PairArray.begin(); i != m_RIP.PairArray.end(); ++i)
{
- if ( sid == i->BodySID )
- {
- start_offset = i->ByteOffset;
- }
- else if ( start_offset != 0 )
- {
- end_offset = i->ByteOffset;
- break;
- }
+ if ( sid == i->BodySID )
+ {
+ assert( start_offset == 0);
+ start_offset = i->ByteOffset;
+ }
+ else if ( start_offset != 0 )
+ {
+ end_offset = i->ByteOffset;
+ break;
+ }
+
+ if ( i->BodySID > 0 )
+ {
+ ++sequence;
+ }
}
if ( start_offset == 0 || end_offset == 0 )
diff --git a/src/KM_fileio.cpp b/src/KM_fileio.cpp
index 07c649f..27a5bfa 100644
--- a/src/KM_fileio.cpp
+++ b/src/KM_fileio.cpp
@@ -1255,8 +1255,8 @@ Kumu::ReadFileIntoString(const std::string& filename, std::string& outString, ui
if ( fsize == 0 )
{
- DefaultLogSink().Error("%s: zero file size\n", filename.c_str());
- return RESULT_READFAIL;
+ outString = "";
+ return RESULT_OK;
}
result = ReadBuf.Capacity((ui32_t)fsize);
diff --git a/src/KM_log.cpp b/src/KM_log.cpp
index 182d91e..d820dba 100755
--- a/src/KM_log.cpp
+++ b/src/KM_log.cpp
@@ -151,7 +151,8 @@ Kumu::StreamLogSink::WriteEntry(const LogEntry& Entry)
if ( Entry.TestFilter(m_filter) )
{
Entry.CreateStringWithOptions(buf, m_options);
- write(m_fd, buf.c_str(), buf.size());
+ ssize_t n = write(m_fd, buf.c_str(), buf.size());
+ assert(n==buf.size());
}
}
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);
diff --git a/src/h__02_Reader.cpp b/src/h__02_Reader.cpp
index 17e9b0d..b3c092b 100644
--- a/src/h__02_Reader.cpp
+++ b/src/h__02_Reader.cpp
@@ -430,10 +430,13 @@ AS_02::h__AS02Reader::OpenMXFRead(const std::string& filename)
}
//
- if ( m_RIP.PairArray.front().ByteOffset != 0 )
+ if ( ! m_RIP.PairArray.empty() )
{
- DefaultLogSink().Error("First Partition in RIP is not at offset 0.\n");
- return RESULT_AS02_FORMAT;
+ if ( m_RIP.PairArray.front().ByteOffset != 0 )
+ {
+ DefaultLogSink().Error("First Partition in RIP is not at offset 0.\n");
+ return RESULT_AS02_FORMAT;
+ }
}
Kumu::fpos_t first_partition_after_header = 0;
diff --git a/src/h__Reader.cpp b/src/h__Reader.cpp
index a764767..77f532e 100755
--- a/src/h__Reader.cpp
+++ b/src/h__Reader.cpp
@@ -108,7 +108,7 @@ ASDCP::h__ASDCPReader::OpenMXFRead(const std::string& filename)
}
}
- if ( m_RIP.PairArray.front().ByteOffset != 0 )
+ if ( !m_RIP.PairArray.empty() && m_RIP.PairArray.front().ByteOffset != 0 )
{
DefaultLogSink().Error("First Partition in RIP is not at offset 0.\n");
result = RESULT_FORMAT;