Skip to content

Commit 3a28346

Browse files
kevinbackhousekmilos
authored andcommitted
Use readOrThrow() to detect premature EOF. (cherry picked from commit fc1fe45)
1 parent 9414a7c commit 3a28346

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/asfvideo.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ void AsfVideo::readMetadata() {
238238

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

243243
size_ = readQWORDTag(io);
244244
if (size_ >= GUID + QWORD)
@@ -296,7 +296,7 @@ void AsfVideo::decodeBlock() {
296296

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

301301
uint32_t nb_headers = Exiv2::getULong(nbHeadersBuf.data(), littleEndian);
302302
Internal::enforce(nb_headers < std::numeric_limits<uint32_t>::max(), Exiv2::ErrorCode::kerCorruptedMetadata);
@@ -358,7 +358,8 @@ void AsfVideo::DegradableJPEGMedia() {
358358
}
359359

360360
void AsfVideo::streamProperties() {
361-
DataBuf streamTypedBuf = io_->read(GUID);
361+
DataBuf streamTypedBuf(GUID);
362+
io_->readOrThrow(streamTypedBuf.data(), streamTypedBuf.size(), Exiv2::ErrorCode::kerCorruptedMetadata);
362363

363364
enum class streamTypeInfo { Audio = 1, Video = 2 };
364365
auto stream = static_cast<streamTypeInfo>(0);
@@ -476,7 +477,8 @@ void AsfVideo::contentDescription() {
476477
} // AsfVideo::extendedContentDescription
477478

478479
void AsfVideo::fileProperties() {
479-
DataBuf FileIddBuf = io_->read(GUID);
480+
DataBuf FileIddBuf(GUID);
481+
io_->readOrThrow(FileIddBuf.data(), FileIddBuf.size(), Exiv2::ErrorCode::kerCorruptedMetadata);
480482
xmpData()["Xmp.video.FileID"] = GUIDTag(FileIddBuf.data()).to_string();
481483
xmpData()["Xmp.video.FileLength"] = readQWORDTag(io_);
482484
xmpData()["Xmp.video.CreationDate"] = readQWORDTag(io_);

0 commit comments

Comments
 (0)