mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
APE: Bounds check the length of values
`pos`, `valLegnth`, and `data.size()` are all unsigned types so we have to do a little dance to correctly bounds check them without overflow. Without this we can get stuck in an infinite loop due to 'pos' overflowing back to the start of the data.
This commit is contained in:
parent
1d3e080f04
commit
03d03f782e
@ -421,6 +421,11 @@ void APE::Tag::parse(const ByteVector &data)
|
||||
const unsigned int keyLength = nullPos - pos - 8;
|
||||
const unsigned int valLegnth = data.toUInt(pos, false);
|
||||
|
||||
if(valLegnth >= data.size() || pos > data.size() - valLegnth) {
|
||||
debug("APE::Tag::parse() - Invalid val length. Stopped parsing.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(keyLength >= MinKeyLength
|
||||
&& keyLength <= MaxKeyLength
|
||||
&& isKeyValid(data.mid(pos + 8, keyLength)))
|
||||
|
Loading…
Reference in New Issue
Block a user