mkvparser_tests: Add invalid block test.

Add test that confirms expected failure when a block
that ends beyond the current cluster is encountered.

Change-Id: I27abcab6d00b78c14b7ca00f51c97e43c5cdd34c
diff --git a/testing/mkvparser_tests.cc b/testing/mkvparser_tests.cc
index 0816632..70306fc 100644
--- a/testing/mkvparser_tests.cc
+++ b/testing/mkvparser_tests.cc
@@ -723,6 +723,16 @@
             segment_->GetFirst()->GetFirst(block_entry));
 }
 
+TEST_F(ParserTest, InvalidBlockEndsBeyondCluster) {
+  ASSERT_NO_FATAL_FAILURE(
+      CreateSegmentNoHeaderChecks("invalid/block_ends_beyond_cluster.mkv"));
+  ASSERT_EQ(0, segment_->Load());
+  const mkvparser::BlockEntry* block_entry = NULL;
+  EXPECT_EQ(0, segment_->GetFirst()->GetFirst(block_entry));
+  EXPECT_EQ(mkvparser::E_FILE_FORMAT_INVALID,
+            segment_->GetFirst()->GetNext(block_entry, block_entry));
+}
+
 }  // namespace test
 
 int main(int argc, char* argv[]) {
diff --git a/testing/testdata/invalid/README.libwebm b/testing/testdata/invalid/README.libwebm
index 56f4ade..871e54d 100644
--- a/testing/testdata/invalid/README.libwebm
+++ b/testing/testdata/invalid/README.libwebm
@@ -1,5 +1,10 @@
 Why the files in this directory are considered invalid:
 
+block_ends_beyond_cluster.mkv -
+  File containing a single cluster with two simple blocks. One valid, and the
+  second reporting a size that would cause the block to end far beyond the end
+  of its parent cluster.
+
 chapters_truncated_chapter_string.mkv -
   File with a Chapters element that ends with a ChapterAtom whose ChapterDisplay
   element contains a truncated ChapterString.
diff --git a/testing/testdata/invalid/block_ends_beyond_cluster.mkv b/testing/testdata/invalid/block_ends_beyond_cluster.mkv
new file mode 100755
index 0000000..3035c8c
--- /dev/null
+++ b/testing/testdata/invalid/block_ends_beyond_cluster.mkv
Binary files differ