Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…l?id=68210

Use readOrThrow() to detect premature EOF.
  • Loading branch information
kevinbackhouse committed Jul 3, 2024
1 parent 1a21ea9 commit d92f313
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/asfvideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void AsfVideo::readMetadata() {

AsfVideo::HeaderReader::HeaderReader(const BasicIo::UniquePtr& io) : IdBuf_(GUID) {
if (io->size() >= io->tell() + GUID + QWORD) {
IdBuf_ = io->read(GUID);
IdBuf_ = io->readOrThrow(GUID, Exiv2::ErrorCode::kerCorruptedMetadata);

size_ = readQWORDTag(io);
if (size_ >= GUID + QWORD)
Expand Down Expand Up @@ -291,7 +291,7 @@ void AsfVideo::decodeBlock() {

void AsfVideo::decodeHeader() {
DataBuf nbHeadersBuf(DWORD + 1);
io_->read(nbHeadersBuf.data(), DWORD);
io_->readOrThrow(nbHeadersBuf.data(), DWORD, Exiv2::ErrorCode::kerCorruptedMetadata);

uint32_t nb_headers = Exiv2::getULong(nbHeadersBuf.data(), littleEndian);
Internal::enforce(nb_headers < std::numeric_limits<uint32_t>::max(), Exiv2::ErrorCode::kerCorruptedMetadata);
Expand Down Expand Up @@ -353,7 +353,7 @@ void AsfVideo::DegradableJPEGMedia() {
}

void AsfVideo::streamProperties() {
DataBuf streamTypedBuf = io_->read(GUID);
DataBuf streamTypedBuf = io_->readOrThrow(GUID, Exiv2::ErrorCode::kerCorruptedMetadata);

enum class streamTypeInfo { Audio = 1, Video = 2 };
auto stream = static_cast<streamTypeInfo>(0);
Expand Down Expand Up @@ -471,7 +471,7 @@ void AsfVideo::contentDescription() {
} // AsfVideo::extendedContentDescription

void AsfVideo::fileProperties() {
DataBuf FileIddBuf = io_->read(GUID);
DataBuf FileIddBuf = io_->readOrThrow(GUID, Exiv2::ErrorCode::kerCorruptedMetadata);
xmpData()["Xmp.video.FileID"] = GUIDTag(FileIddBuf.data()).to_string();
xmpData()["Xmp.video.FileLength"] = readQWORDTag(io_);
xmpData()["Xmp.video.CreationDate"] = readQWORDTag(io_);
Expand Down

0 comments on commit d92f313

Please sign in to comment.