| 579 | } // QuickTimeVideo::readMetadata |
| 580 | |
| 581 | void QuickTimeVideo::decodeBlock(size_t recursion_depth, std::string const& entered_from) { |
| 582 | enforce(recursion_depth < max_recursion_depth_, Exiv2::ErrorCode::kerCorruptedMetadata); |
| 583 | |
| 584 | const long bufMinSize = 4; |
| 585 | DataBuf buf(bufMinSize + 1); |
| 586 | uint64_t size = 0; |
| 587 | buf.data()[4] = '\0'; |
| 588 | |
| 589 | io_->read(buf.data(), 4); |
| 590 | if (io_->eof()) { |
| 591 | continueTraversing_ = false; |
| 592 | return; |
| 593 | } |
| 594 | |
| 595 | size = buf.read_uint32(0, bigEndian); |
| 596 | |
| 597 | io_->readOrThrow(buf.data(), 4); |
| 598 | |
| 599 | // we have read 2x 4 bytes |
| 600 | size_t hdrsize = 8; |
| 601 | |
| 602 | if (size == 1) { |
| 603 | // The box size is encoded as a uint64_t, so we need to read another 8 bytes. |
| 604 | DataBuf data(8); |
| 605 | hdrsize += 8; |
| 606 | io_->readOrThrow(data.data(), data.size()); |
| 607 | size = data.read_uint64(0, bigEndian); |
| 608 | } else if (size == 0 && entered_from == "meta") { |
| 609 | size = buf.read_uint32(0, bigEndian); |
| 610 | io_->readOrThrow(buf.data(), 4, Exiv2::ErrorCode::kerCorruptedMetadata); |
| 611 | } |
| 612 | |
| 613 | enforce(size >= hdrsize, Exiv2::ErrorCode::kerCorruptedMetadata); |
| 614 | enforce(size - hdrsize <= io_->size() - io_->tell(), Exiv2::ErrorCode::kerCorruptedMetadata); |
| 615 | enforce(size - hdrsize <= std::numeric_limits<size_t>::max(), Exiv2::ErrorCode::kerCorruptedMetadata); |
| 616 | |
| 617 | // std::cerr<<"Tag=>"<<buf.data()<<" size=>"<<size-hdrsize << std::endl; |
| 618 | const auto newsize = static_cast<size_t>(size - hdrsize); |
| 619 | if (newsize > buf.size()) { |
| 620 | buf.resize(newsize); |
| 621 | } |
| 622 | tagDecoder(buf, newsize, recursion_depth + 1); |
| 623 | } // QuickTimeVideo::decodeBlock |
| 624 | |
| 625 | static std::string readString(BasicIo& io, size_t size) { |
| 626 | enforce(size <= io.size() - io.tell(), Exiv2::ErrorCode::kerCorruptedMetadata); |
nothing calls this directly
no test coverage detected