Skip to content

Commit 35a6b8f

Browse files
Merge pull request #3005 from kevinbackhouse/asfvideo-readOrThrow
Use readOrThrow() to detect premature EOF
2 parents 1a21ea9 + fc1fe45 commit 35a6b8f

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
@@ -235,7 +235,7 @@ void AsfVideo::readMetadata() {
235235

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

240240
size_ = readQWORDTag(io);
241241
if (size_ >= GUID + QWORD)
@@ -291,7 +291,7 @@ void AsfVideo::decodeBlock() {
291291

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

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

355355
void AsfVideo::streamProperties() {
356-
DataBuf streamTypedBuf = io_->read(GUID);
356+
DataBuf streamTypedBuf(GUID);
357+
io_->readOrThrow(streamTypedBuf.data(), streamTypedBuf.size(), Exiv2::ErrorCode::kerCorruptedMetadata);
357358

358359
enum class streamTypeInfo { Audio = 1, Video = 2 };
359360
auto stream = static_cast<streamTypeInfo>(0);
@@ -471,7 +472,8 @@ void AsfVideo::contentDescription() {
471472
} // AsfVideo::extendedContentDescription
472473

473474
void AsfVideo::fileProperties() {
474-
DataBuf FileIddBuf = io_->read(GUID);
475+
DataBuf FileIddBuf(GUID);
476+
io_->readOrThrow(FileIddBuf.data(), FileIddBuf.size(), Exiv2::ErrorCode::kerCorruptedMetadata);
475477
xmpData()["Xmp.video.FileID"] = GUIDTag(FileIddBuf.data()).to_string();
476478
xmpData()["Xmp.video.FileLength"] = readQWORDTag(io_);
477479
xmpData()["Xmp.video.CreationDate"] = readQWORDTag(io_);

0 commit comments

Comments
 (0)