Skip to content

Commit 05beb69

Browse files
committed
Check the max size to read before actually reading
The size check waas also missing from the length parsing
1 parent d559b0d commit 05beb69

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: src/EbmlElement.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,14 @@ EbmlElement * EbmlElement::FindNextElement(IOCallback & DataStream, const EbmlSe
404404
memmove(&PossibleIdNSize[0],&PossibleIdNSize[1], --ReadIndex);
405405
}
406406

407+
if (MaxDataSize <= ReadSize)
408+
break;
407409
if (DataStream.read(&PossibleIdNSize[ReadIndex++], 1) == 0) {
408410
return NULL; // no more data ?
409411
}
410412
ReadSize++;
411413

412-
} while (!bFound && MaxDataSize > ReadSize);
414+
} while (!bFound);
413415

414416
if (!bFound)
415417
// we reached the maximum we could read without a proper ID
@@ -432,6 +434,10 @@ EbmlElement * EbmlElement::FindNextElement(IOCallback & DataStream, const EbmlSe
432434
bFound = false;
433435
break;
434436
}
437+
if (MaxDataSize <= ReadSize) {
438+
bFound = false;
439+
break;
440+
}
435441
if( DataStream.read( &PossibleIdNSize[SizeIdx++], 1 ) == 0 ) {
436442
return NULL; // no more data ?
437443
}

0 commit comments

Comments
 (0)