summaryrefslogtreecommitdiff
path: root/src/Index.cpp
diff options
context:
space:
mode:
authorjhurst <jhurst@cinecert.com>2016-06-28 22:00:06 +0000
committerjhurst <>2016-06-28 22:00:06 +0000
commit976a32de62b29ed688abecdebd6cb57f3ed299e7 (patch)
treeb402cc53c5141043d5282b8b5907f87724bf492c /src/Index.cpp
parent7fc5128ca2651e66913f26f0d2e4129511d89afd (diff)
o Fixed a bug in the index reader that allowed an out-of-bounds vector index to be used
o Modified the IndexEntry parser to ignore additional bytes belonging to slice values
Diffstat (limited to 'src/Index.cpp')
-rwxr-xr-xsrc/Index.cpp43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/Index.cpp b/src/Index.cpp
index f996339..6406e0f 100755
--- a/src/Index.cpp
+++ b/src/Index.cpp
@@ -79,7 +79,42 @@ ASDCP::MXF::IndexTableSegment::InitFromTLVSet(TLVReader& TLVSet)
if ( ASDCP_SUCCESS(result) ) result = TLVSet.ReadUi8(OBJ_READ_ARGS(IndexTableSegmentBase, SliceCount));
if ( ASDCP_SUCCESS(result) ) result = TLVSet.ReadUi8(OBJ_READ_ARGS(IndexTableSegmentBase, PosTableCount));
if ( ASDCP_SUCCESS(result) ) result = TLVSet.ReadObject(OBJ_READ_ARGS(IndexTableSegment, DeltaEntryArray));
- if ( ASDCP_SUCCESS(result) ) result = TLVSet.ReadObject(OBJ_READ_ARGS(IndexTableSegment, IndexEntryArray));
+
+ if ( ASDCP_SUCCESS(result) )
+ {
+ bool rc = TLVSet.FindTL(m_Dict->Type(MDD_IndexTableSegment_IndexEntryArray));
+
+ if ( rc )
+ {
+ ui32_t item_count, item_size;
+ ui32_t const decoder_item_size = IndexEntryArray.ItemSize();
+
+ if ( TLVSet.ReadUi32BE(&item_count) )
+ {
+ if ( TLVSet.ReadUi32BE(&item_size) )
+ {
+ for ( ui32_t i = 0; i < item_count && rc; ++i )
+ {
+ IndexEntry tmp_item;
+ rc = tmp_item.Unarchive(&TLVSet);
+
+ if ( rc )
+ {
+ IndexEntryArray.push_back(tmp_item);
+
+ if ( decoder_item_size < item_size )
+ {
+ TLVSet.SkipOffset(item_size - decoder_item_size);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ result = rc ? RESULT_OK : RESULT_FALSE;
+ }
+
return result;
}
@@ -136,7 +171,11 @@ ASDCP::MXF::IndexTableSegment::Dump(FILE* stream)
fprintf(stream, " DeltaEntryArray:\n"); DeltaEntryArray.Dump(stream);
- if ( IndexEntryArray.size() < 1000 )
+ if ( IndexEntryArray.empty() )
+ {
+ fprintf(stream, " IndexEntryArray: NO ENTRIES\n");
+ }
+ else if ( IndexEntryArray.size() < 1000 )
{
fprintf(stream, " IndexEntryArray:\n");
IndexEntryArray.Dump(stream);