Skip to content
Permalink
Browse files Browse the repository at this point in the history
Check the max size to read before actually reading
The size check waas also missing from the length parsing
  • Loading branch information
robUx4 committed Nov 27, 2017
1 parent d559b0d commit 05beb69
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/EbmlElement.cpp
Expand Up @@ -404,12 +404,14 @@ EbmlElement * EbmlElement::FindNextElement(IOCallback & DataStream, const EbmlSe
memmove(&PossibleIdNSize[0],&PossibleIdNSize[1], --ReadIndex);
}

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

} while (!bFound && MaxDataSize > ReadSize);
} while (!bFound);

if (!bFound)
// we reached the maximum we could read without a proper ID
Expand All @@ -432,6 +434,10 @@ EbmlElement * EbmlElement::FindNextElement(IOCallback & DataStream, const EbmlSe
bFound = false;
break;
}
if (MaxDataSize <= ReadSize) {
bFound = false;
break;
}
if( DataStream.read( &PossibleIdNSize[SizeIdx++], 1 ) == 0 ) {
return NULL; // no more data ?
}
Expand Down

0 comments on commit 05beb69

Please sign in to comment.