| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/formats/mp4/box_reader.h" | 5 #include "media/formats/mp4/box_reader.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 SkipBox(); | 77 SkipBox(); |
| 78 ~SkipBox() override; | 78 ~SkipBox() override; |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 SkipBox::SkipBox() {} | 81 SkipBox::SkipBox() {} |
| 82 SkipBox::~SkipBox() {} | 82 SkipBox::~SkipBox() {} |
| 83 | 83 |
| 84 class BoxReaderTest : public testing::Test { | 84 class BoxReaderTest : public testing::Test { |
| 85 public: | 85 public: |
| 86 BoxReaderTest() : media_log_(new StrictMock<MockMediaLog>()) {} | 86 BoxReaderTest() {} |
| 87 | 87 |
| 88 protected: | 88 protected: |
| 89 std::vector<uint8_t> GetBuf() { | 89 std::vector<uint8_t> GetBuf() { |
| 90 return std::vector<uint8_t>(kSkipBox, kSkipBox + sizeof(kSkipBox)); | 90 return std::vector<uint8_t>(kSkipBox, kSkipBox + sizeof(kSkipBox)); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void TestTopLevelBox(const uint8_t* data, size_t data_size, uint32_t fourCC) { | 93 void TestTopLevelBox(const uint8_t* data, size_t data_size, uint32_t fourCC) { |
| 94 std::vector<uint8_t> buf(data, data + data_size); | 94 std::vector<uint8_t> buf(data, data + data_size); |
| 95 | 95 |
| 96 bool err; | 96 bool err; |
| 97 std::unique_ptr<BoxReader> reader( | 97 std::unique_ptr<BoxReader> reader( |
| 98 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), media_log_, &err)); | 98 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), &media_log_, &err)); |
| 99 | 99 |
| 100 EXPECT_FALSE(err); | 100 EXPECT_FALSE(err); |
| 101 EXPECT_TRUE(reader); | 101 EXPECT_TRUE(reader); |
| 102 EXPECT_EQ(fourCC, reader->type()); | 102 EXPECT_EQ(fourCC, reader->type()); |
| 103 EXPECT_EQ(reader->box_size(), data_size); | 103 EXPECT_EQ(reader->box_size(), data_size); |
| 104 } | 104 } |
| 105 | 105 |
| 106 template <typename ChildType> | 106 template <typename ChildType> |
| 107 void TestParsing32bitOverflow(const uint8_t* buffer, | 107 void TestParsing32bitOverflow(const uint8_t* buffer, |
| 108 size_t size, | 108 size_t size, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 120 ASSERT_TRUE(base::IsValueInRangeForNumericType<uint8_t>(size)); | 120 ASSERT_TRUE(base::IsValueInRangeForNumericType<uint8_t>(size)); |
| 121 ASSERT_LE(buffer[3], size); | 121 ASSERT_LE(buffer[3], size); |
| 122 | 122 |
| 123 // Update the size (keep it simple). | 123 // Update the size (keep it simple). |
| 124 ASSERT_TRUE( | 124 ASSERT_TRUE( |
| 125 base::IsValueInRangeForNumericType<uint8_t>(buffer_wrapper.size())); | 125 base::IsValueInRangeForNumericType<uint8_t>(buffer_wrapper.size())); |
| 126 buffer_wrapper[3] = buffer_wrapper.size(); | 126 buffer_wrapper[3] = buffer_wrapper.size(); |
| 127 | 127 |
| 128 bool err; | 128 bool err; |
| 129 std::unique_ptr<BoxReader> reader(BoxReader::ReadTopLevelBox( | 129 std::unique_ptr<BoxReader> reader(BoxReader::ReadTopLevelBox( |
| 130 &buffer_wrapper[0], buffer_wrapper.size(), media_log_, &err)); | 130 &buffer_wrapper[0], buffer_wrapper.size(), &media_log_, &err)); |
| 131 EXPECT_FALSE(err); | 131 EXPECT_FALSE(err); |
| 132 EXPECT_TRUE(reader); | 132 EXPECT_TRUE(reader); |
| 133 EXPECT_EQ(FOURCC_EMSG, reader->type()); | 133 EXPECT_EQ(FOURCC_EMSG, reader->type()); |
| 134 | 134 |
| 135 // Overflow is only triggered/caught on 32-bit systems. 64-bit systems will | 135 // Overflow is only triggered/caught on 32-bit systems. 64-bit systems will |
| 136 // instead fail parsing because tests are written such that |buffer| never | 136 // instead fail parsing because tests are written such that |buffer| never |
| 137 // contains enough bytes for parsing to succeed. | 137 // contains enough bytes for parsing to succeed. |
| 138 #if defined(ARCH_CPU_32_BITS) | 138 #if defined(ARCH_CPU_32_BITS) |
| 139 const int kOverflowLogCount = 1; | 139 const int kOverflowLogCount = 1; |
| 140 #else | 140 #else |
| 141 const int kOverflowLogCount = 0; | 141 const int kOverflowLogCount = 0; |
| 142 #endif | 142 #endif |
| 143 | 143 |
| 144 if (!overflow_error.empty()) | 144 if (!overflow_error.empty()) |
| 145 EXPECT_MEDIA_LOG(HasSubstr(overflow_error)).Times(kOverflowLogCount); | 145 EXPECT_MEDIA_LOG(HasSubstr(overflow_error)).Times(kOverflowLogCount); |
| 146 | 146 |
| 147 std::vector<ChildType> children; | 147 std::vector<ChildType> children; |
| 148 EXPECT_FALSE(reader->ReadAllChildrenAndCheckFourCC(&children)); | 148 EXPECT_FALSE(reader->ReadAllChildrenAndCheckFourCC(&children)); |
| 149 } | 149 } |
| 150 | 150 |
| 151 scoped_refptr<StrictMock<MockMediaLog>> media_log_; | 151 StrictMock<MockMediaLog> media_log_; |
| 152 }; | 152 }; |
| 153 | 153 |
| 154 TEST_F(BoxReaderTest, ExpectedOperationTest) { | 154 TEST_F(BoxReaderTest, ExpectedOperationTest) { |
| 155 std::vector<uint8_t> buf = GetBuf(); | 155 std::vector<uint8_t> buf = GetBuf(); |
| 156 bool err; | 156 bool err; |
| 157 std::unique_ptr<BoxReader> reader( | 157 std::unique_ptr<BoxReader> reader( |
| 158 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), media_log_, &err)); | 158 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), &media_log_, &err)); |
| 159 EXPECT_FALSE(err); | 159 EXPECT_FALSE(err); |
| 160 EXPECT_TRUE(reader.get()); | 160 EXPECT_TRUE(reader.get()); |
| 161 | 161 |
| 162 SkipBox box; | 162 SkipBox box; |
| 163 EXPECT_TRUE(box.Parse(reader.get())); | 163 EXPECT_TRUE(box.Parse(reader.get())); |
| 164 EXPECT_EQ(0x01, reader->version()); | 164 EXPECT_EQ(0x01, reader->version()); |
| 165 EXPECT_EQ(0x020304u, reader->flags()); | 165 EXPECT_EQ(0x020304u, reader->flags()); |
| 166 EXPECT_EQ(0x05, box.a); | 166 EXPECT_EQ(0x05, box.a); |
| 167 EXPECT_EQ(0x06, box.b); | 167 EXPECT_EQ(0x06, box.b); |
| 168 EXPECT_EQ(0x0708, box.c); | 168 EXPECT_EQ(0x0708, box.c); |
| 169 EXPECT_EQ(static_cast<int32_t>(0xf90a0b0c), box.d); | 169 EXPECT_EQ(static_cast<int32_t>(0xf90a0b0c), box.d); |
| 170 EXPECT_EQ(static_cast<int32_t>(0xfd0e0f10), box.e); | 170 EXPECT_EQ(static_cast<int32_t>(0xfd0e0f10), box.e); |
| 171 | 171 |
| 172 EXPECT_EQ(2u, box.kids.size()); | 172 EXPECT_EQ(2u, box.kids.size()); |
| 173 EXPECT_EQ(0xdeadbeef, box.kids[0].val); | 173 EXPECT_EQ(0xdeadbeef, box.kids[0].val); |
| 174 EXPECT_EQ(0xfacecafe, box.kids[1].val); | 174 EXPECT_EQ(0xfacecafe, box.kids[1].val); |
| 175 | 175 |
| 176 // Accounting for the extra byte outside of the box above | 176 // Accounting for the extra byte outside of the box above |
| 177 EXPECT_EQ(buf.size(), static_cast<uint64_t>(reader->box_size() + 1)); | 177 EXPECT_EQ(buf.size(), static_cast<uint64_t>(reader->box_size() + 1)); |
| 178 } | 178 } |
| 179 | 179 |
| 180 TEST_F(BoxReaderTest, OuterTooShortTest) { | 180 TEST_F(BoxReaderTest, OuterTooShortTest) { |
| 181 std::vector<uint8_t> buf = GetBuf(); | 181 std::vector<uint8_t> buf = GetBuf(); |
| 182 bool err; | 182 bool err; |
| 183 | 183 |
| 184 // Create a soft failure by truncating the outer box. | 184 // Create a soft failure by truncating the outer box. |
| 185 std::unique_ptr<BoxReader> r( | 185 std::unique_ptr<BoxReader> r( |
| 186 BoxReader::ReadTopLevelBox(&buf[0], buf.size() - 2, media_log_, &err)); | 186 BoxReader::ReadTopLevelBox(&buf[0], buf.size() - 2, &media_log_, &err)); |
| 187 | 187 |
| 188 EXPECT_FALSE(err); | 188 EXPECT_FALSE(err); |
| 189 EXPECT_FALSE(r.get()); | 189 EXPECT_FALSE(r.get()); |
| 190 } | 190 } |
| 191 | 191 |
| 192 TEST_F(BoxReaderTest, InnerTooLongTest) { | 192 TEST_F(BoxReaderTest, InnerTooLongTest) { |
| 193 std::vector<uint8_t> buf = GetBuf(); | 193 std::vector<uint8_t> buf = GetBuf(); |
| 194 bool err; | 194 bool err; |
| 195 | 195 |
| 196 // Make an inner box too big for its outer box. | 196 // Make an inner box too big for its outer box. |
| 197 buf[25] = 1; | 197 buf[25] = 1; |
| 198 std::unique_ptr<BoxReader> reader( | 198 std::unique_ptr<BoxReader> reader( |
| 199 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), media_log_, &err)); | 199 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), &media_log_, &err)); |
| 200 | 200 |
| 201 SkipBox box; | 201 SkipBox box; |
| 202 EXPECT_FALSE(box.Parse(reader.get())); | 202 EXPECT_FALSE(box.Parse(reader.get())); |
| 203 } | 203 } |
| 204 | 204 |
| 205 TEST_F(BoxReaderTest, WrongFourCCTest) { | 205 TEST_F(BoxReaderTest, WrongFourCCTest) { |
| 206 std::vector<uint8_t> buf = GetBuf(); | 206 std::vector<uint8_t> buf = GetBuf(); |
| 207 bool err; | 207 bool err; |
| 208 | 208 |
| 209 // Set an unrecognized top-level FourCC. | 209 // Set an unrecognized top-level FourCC. |
| 210 buf[4] = 0x44; | 210 buf[4] = 0x44; |
| 211 buf[5] = 0x41; | 211 buf[5] = 0x41; |
| 212 buf[6] = 0x4c; | 212 buf[6] = 0x4c; |
| 213 buf[7] = 0x45; | 213 buf[7] = 0x45; |
| 214 | 214 |
| 215 EXPECT_MEDIA_LOG(HasSubstr("Unrecognized top-level box type DALE")); | 215 EXPECT_MEDIA_LOG(HasSubstr("Unrecognized top-level box type DALE")); |
| 216 | 216 |
| 217 std::unique_ptr<BoxReader> reader( | 217 std::unique_ptr<BoxReader> reader( |
| 218 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), media_log_, &err)); | 218 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), &media_log_, &err)); |
| 219 EXPECT_FALSE(reader.get()); | 219 EXPECT_FALSE(reader.get()); |
| 220 EXPECT_TRUE(err); | 220 EXPECT_TRUE(err); |
| 221 } | 221 } |
| 222 | 222 |
| 223 TEST_F(BoxReaderTest, ScanChildrenTest) { | 223 TEST_F(BoxReaderTest, ScanChildrenTest) { |
| 224 std::vector<uint8_t> buf = GetBuf(); | 224 std::vector<uint8_t> buf = GetBuf(); |
| 225 bool err; | 225 bool err; |
| 226 std::unique_ptr<BoxReader> reader( | 226 std::unique_ptr<BoxReader> reader( |
| 227 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), media_log_, &err)); | 227 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), &media_log_, &err)); |
| 228 | 228 |
| 229 EXPECT_TRUE(reader->SkipBytes(16) && reader->ScanChildren()); | 229 EXPECT_TRUE(reader->SkipBytes(16) && reader->ScanChildren()); |
| 230 | 230 |
| 231 FreeBox free; | 231 FreeBox free; |
| 232 EXPECT_TRUE(reader->ReadChild(&free)); | 232 EXPECT_TRUE(reader->ReadChild(&free)); |
| 233 EXPECT_FALSE(reader->ReadChild(&free)); | 233 EXPECT_FALSE(reader->ReadChild(&free)); |
| 234 EXPECT_TRUE(reader->MaybeReadChild(&free)); | 234 EXPECT_TRUE(reader->MaybeReadChild(&free)); |
| 235 | 235 |
| 236 std::vector<PsshBox> kids; | 236 std::vector<PsshBox> kids; |
| 237 | 237 |
| 238 EXPECT_TRUE(reader->ReadChildren(&kids)); | 238 EXPECT_TRUE(reader->ReadChildren(&kids)); |
| 239 EXPECT_EQ(2u, kids.size()); | 239 EXPECT_EQ(2u, kids.size()); |
| 240 kids.clear(); | 240 kids.clear(); |
| 241 EXPECT_FALSE(reader->ReadChildren(&kids)); | 241 EXPECT_FALSE(reader->ReadChildren(&kids)); |
| 242 EXPECT_TRUE(reader->MaybeReadChildren(&kids)); | 242 EXPECT_TRUE(reader->MaybeReadChildren(&kids)); |
| 243 } | 243 } |
| 244 | 244 |
| 245 TEST_F(BoxReaderTest, ReadAllChildrenTest) { | 245 TEST_F(BoxReaderTest, ReadAllChildrenTest) { |
| 246 std::vector<uint8_t> buf = GetBuf(); | 246 std::vector<uint8_t> buf = GetBuf(); |
| 247 // Modify buffer to exclude its last 'free' box | 247 // Modify buffer to exclude its last 'free' box |
| 248 buf[3] = 0x38; | 248 buf[3] = 0x38; |
| 249 bool err; | 249 bool err; |
| 250 std::unique_ptr<BoxReader> reader( | 250 std::unique_ptr<BoxReader> reader( |
| 251 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), media_log_, &err)); | 251 BoxReader::ReadTopLevelBox(&buf[0], buf.size(), &media_log_, &err)); |
| 252 | 252 |
| 253 std::vector<PsshBox> kids; | 253 std::vector<PsshBox> kids; |
| 254 EXPECT_TRUE(reader->SkipBytes(16) && reader->ReadAllChildren(&kids)); | 254 EXPECT_TRUE(reader->SkipBytes(16) && reader->ReadAllChildren(&kids)); |
| 255 EXPECT_EQ(2u, kids.size()); | 255 EXPECT_EQ(2u, kids.size()); |
| 256 EXPECT_EQ(kids[0].val, 0xdeadbeef); // Ensure order is preserved | 256 EXPECT_EQ(kids[0].val, 0xdeadbeef); // Ensure order is preserved |
| 257 } | 257 } |
| 258 | 258 |
| 259 TEST_F(BoxReaderTest, SkippingBloc) { | 259 TEST_F(BoxReaderTest, SkippingBloc) { |
| 260 static const uint8_t kData[] = {0x00, 0x00, 0x00, 0x09, 'b', | 260 static const uint8_t kData[] = {0x00, 0x00, 0x00, 0x09, 'b', |
| 261 'l', 'o', 'c', 0x00}; | 261 'l', 'o', 'c', 0x00}; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 // integer overflows. The nested box should not specify more than the | 299 // integer overflows. The nested box should not specify more than the |
| 300 // number of remaining bytes in the enclosing box. | 300 // number of remaining bytes in the enclosing box. |
| 301 static const uint8_t kData[] = { | 301 static const uint8_t kData[] = { |
| 302 0x00, 0x00, 0x00, 0x24, 'e', 'm', 's', 'g', // outer box | 302 0x00, 0x00, 0x00, 0x24, 'e', 'm', 's', 'g', // outer box |
| 303 0x7f, 0xff, 0xff, 0xff, 'j', 'u', 'n', 'k', // nested box | 303 0x7f, 0xff, 0xff, 0xff, 'j', 'u', 'n', 'k', // nested box |
| 304 0x00, 0x01, 0x00, 0xff, 0xff, 0x00, 0x3b, 0x03, // random data for rest | 304 0x00, 0x01, 0x00, 0xff, 0xff, 0x00, 0x3b, 0x03, // random data for rest |
| 305 0x00, 0x01, 0x00, 0x03, 0x00, 0x03, 0x00, 0x04, 0x05, 0x06, 0x07, 0x08}; | 305 0x00, 0x01, 0x00, 0x03, 0x00, 0x03, 0x00, 0x04, 0x05, 0x06, 0x07, 0x08}; |
| 306 | 306 |
| 307 bool err; | 307 bool err; |
| 308 std::unique_ptr<BoxReader> reader( | 308 std::unique_ptr<BoxReader> reader( |
| 309 BoxReader::ReadTopLevelBox(kData, sizeof(kData), media_log_, &err)); | 309 BoxReader::ReadTopLevelBox(kData, sizeof(kData), &media_log_, &err)); |
| 310 | 310 |
| 311 EXPECT_FALSE(err); | 311 EXPECT_FALSE(err); |
| 312 EXPECT_TRUE(reader); | 312 EXPECT_TRUE(reader); |
| 313 EXPECT_EQ(FOURCC_EMSG, reader->type()); | 313 EXPECT_EQ(FOURCC_EMSG, reader->type()); |
| 314 EXPECT_FALSE(reader->ScanChildren()); | 314 EXPECT_FALSE(reader->ScanChildren()); |
| 315 } | 315 } |
| 316 | 316 |
| 317 TEST_F(BoxReaderTest, ScanChildrenWithInvalidChild) { | 317 TEST_F(BoxReaderTest, ScanChildrenWithInvalidChild) { |
| 318 // This data is not a valid 'emsg' box. It is just used as a top-level box | 318 // This data is not a valid 'emsg' box. It is just used as a top-level box |
| 319 // as ReadTopLevelBox() has a restricted set of boxes it allows. | 319 // as ReadTopLevelBox() has a restricted set of boxes it allows. |
| 320 // The nested 'elst' box is used as it includes a count of EditListEntry's. | 320 // The nested 'elst' box is used as it includes a count of EditListEntry's. |
| 321 // The sample specifies a large number of EditListEntry's, but only 1 is | 321 // The sample specifies a large number of EditListEntry's, but only 1 is |
| 322 // actually included in the box. This test verifies that the code checks | 322 // actually included in the box. This test verifies that the code checks |
| 323 // properly that the buffer contains the specified number of EditListEntry's | 323 // properly that the buffer contains the specified number of EditListEntry's |
| 324 static const uint8_t kData[] = { | 324 static const uint8_t kData[] = { |
| 325 0x00, 0x00, 0x00, 0x2c, 'e', 'm', 's', 'g', // outer box | 325 0x00, 0x00, 0x00, 0x2c, 'e', 'm', 's', 'g', // outer box |
| 326 0x00, 0x00, 0x00, 0x24, 'e', 'l', 's', 't', // nested box | 326 0x00, 0x00, 0x00, 0x24, 'e', 'l', 's', 't', // nested box |
| 327 0x01, 0x00, 0x00, 0x00, // version = 1, flags = 0 | 327 0x01, 0x00, 0x00, 0x00, // version = 1, flags = 0 |
| 328 0x00, 0x00, 0x00, 0x0a, // count = 10, but only 1 actually included | 328 0x00, 0x00, 0x00, 0x0a, // count = 10, but only 1 actually included |
| 329 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 329 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 330 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | 330 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 331 | 331 |
| 332 bool err; | 332 bool err; |
| 333 std::unique_ptr<BoxReader> reader( | 333 std::unique_ptr<BoxReader> reader( |
| 334 BoxReader::ReadTopLevelBox(kData, sizeof(kData), media_log_, &err)); | 334 BoxReader::ReadTopLevelBox(kData, sizeof(kData), &media_log_, &err)); |
| 335 | 335 |
| 336 EXPECT_FALSE(err); | 336 EXPECT_FALSE(err); |
| 337 EXPECT_TRUE(reader); | 337 EXPECT_TRUE(reader); |
| 338 EXPECT_EQ(FOURCC_EMSG, reader->type()); | 338 EXPECT_EQ(FOURCC_EMSG, reader->type()); |
| 339 EXPECT_TRUE(reader->ScanChildren()); | 339 EXPECT_TRUE(reader->ScanChildren()); |
| 340 | 340 |
| 341 // 'elst' specifies lots of EditListEntry's but only includes 1. Thus | 341 // 'elst' specifies lots of EditListEntry's but only includes 1. Thus |
| 342 // parsing it should fail. | 342 // parsing it should fail. |
| 343 EditList child; | 343 EditList child; |
| 344 EXPECT_FALSE(reader->ReadChild(&child)); | 344 EXPECT_FALSE(reader->ReadChild(&child)); |
| 345 } | 345 } |
| 346 | 346 |
| 347 TEST_F(BoxReaderTest, ReadAllChildrenWithChildLargerThanParent) { | 347 TEST_F(BoxReaderTest, ReadAllChildrenWithChildLargerThanParent) { |
| 348 static const uint8_t kData[] = { | 348 static const uint8_t kData[] = { |
| 349 0x00, 0x00, 0x00, 0x10, 's', 'k', 'i', 'p', // outer box | 349 0x00, 0x00, 0x00, 0x10, 's', 'k', 'i', 'p', // outer box |
| 350 0x00, 0x00, 0x00, 0x10, 'p', 's', 's', 'h', // nested box | 350 0x00, 0x00, 0x00, 0x10, 'p', 's', 's', 'h', // nested box |
| 351 }; | 351 }; |
| 352 | 352 |
| 353 bool err; | 353 bool err; |
| 354 std::unique_ptr<BoxReader> reader( | 354 std::unique_ptr<BoxReader> reader( |
| 355 BoxReader::ReadTopLevelBox(kData, sizeof(kData), media_log_, &err)); | 355 BoxReader::ReadTopLevelBox(kData, sizeof(kData), &media_log_, &err)); |
| 356 | 356 |
| 357 EXPECT_FALSE(err); | 357 EXPECT_FALSE(err); |
| 358 EXPECT_TRUE(reader); | 358 EXPECT_TRUE(reader); |
| 359 EXPECT_EQ(FOURCC_SKIP, reader->type()); | 359 EXPECT_EQ(FOURCC_SKIP, reader->type()); |
| 360 | 360 |
| 361 std::vector<PsshBox> tmp; | 361 std::vector<PsshBox> tmp; |
| 362 EXPECT_FALSE(reader->ReadAllChildren(&tmp)); | 362 EXPECT_FALSE(reader->ReadAllChildren(&tmp)); |
| 363 } | 363 } |
| 364 | 364 |
| 365 TEST_F(BoxReaderTest, TrunSampleCount32bitOverflow) { | 365 TEST_F(BoxReaderTest, TrunSampleCount32bitOverflow) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 0x00, 0x00, 0x00, 0x00, | 455 0x00, 0x00, 0x00, 0x00, |
| 456 }; | 456 }; |
| 457 | 457 |
| 458 // Verify we catch the overflow to avoid OOB reads/writes. | 458 // Verify we catch the overflow to avoid OOB reads/writes. |
| 459 TestParsing32bitOverflow<SampleGroupDescription>( | 459 TestParsing32bitOverflow<SampleGroupDescription>( |
| 460 kData, sizeof(kData), "Extreme SGPD count exceeds implementation limit."); | 460 kData, sizeof(kData), "Extreme SGPD count exceeds implementation limit."); |
| 461 } | 461 } |
| 462 | 462 |
| 463 } // namespace mp4 | 463 } // namespace mp4 |
| 464 } // namespace media | 464 } // namespace media |
| OLD | NEW |