Commit 3f848c36 authored by wolenetz@chromium.org's avatar wolenetz@chromium.org

Report parse error for WebM clusters missing a timecode

Replaces a DCHECK with parse error when parsing a WebM
cluster that has no timecode. This supplements the existing
WebMClusterParser::OnBlock() logic that similarly indicates
parse error when processing blocks. However, if there were
no blocks in the cluster, then the DCHECK could have been
hit if there were no timecode.

R=acolwell@chromium.org
BUG=335344
TEST=(local Linux) All media_unittests pass including the new ones

Review URL: https://codereview.chromium.org/141013008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245608 0039d316-1c4b-4281-b951-d872f2087c98
parent 017f2d2c
...@@ -110,7 +110,11 @@ int WebMClusterParser::Parse(const uint8* buf, int size) { ...@@ -110,7 +110,11 @@ int WebMClusterParser::Parse(const uint8* buf, int size) {
// If there were no buffers in this cluster, set the cluster start time to // If there were no buffers in this cluster, set the cluster start time to
// be the |cluster_timecode_|. // be the |cluster_timecode_|.
if (cluster_start_time_ == kNoTimestamp()) { if (cluster_start_time_ == kNoTimestamp()) {
DCHECK_GT(cluster_timecode_, -1); // If the cluster did not even have a |cluster_timecode_|, signal parse
// error.
if (cluster_timecode_ < 0)
return -1;
cluster_start_time_ = base::TimeDelta::FromMicroseconds( cluster_start_time_ = base::TimeDelta::FromMicroseconds(
cluster_timecode_ * timecode_multiplier_); cluster_timecode_ * timecode_multiplier_);
} }
......
...@@ -525,4 +525,21 @@ TEST_F(WebMClusterParserTest, ParseBadEncryptedBlock) { ...@@ -525,4 +525,21 @@ TEST_F(WebMClusterParserTest, ParseBadEncryptedBlock) {
EXPECT_EQ(-1, result); EXPECT_EQ(-1, result);
} }
TEST_F(WebMClusterParserTest, ParseInvalidZeroSizedCluster) {
const uint8 kBuffer[] = {
0x1F, 0x43, 0xB6, 0x75, 0x80, // CLUSTER (size = 0)
};
EXPECT_EQ(parser_->Parse(kBuffer, sizeof(kBuffer)), -1);
}
TEST_F(WebMClusterParserTest, ParseInvalidUnknownButActuallyZeroSizedCluster) {
const uint8 kBuffer[] = {
0x1F, 0x43, 0xB6, 0x75, 0xFF, // CLUSTER (size = "unknown")
0x1F, 0x43, 0xB6, 0x75, 0x85, // CLUSTER (size = 5)
};
EXPECT_EQ(parser_->Parse(kBuffer, sizeof(kBuffer)), -1);
}
} // namespace media } // namespace media
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment