mirror of
https://github.com/taglib/taglib.git
synced 2026-08-14 06:17:00 -04:00
Xiph: limit parsed comment fields (#1397)
Xiph comment parsing retained an unbounded number of fields. A crafted comment block with many small fields could consume disproportionate memory. Stop parsing comment fields when the parser limit is exceeded.
This commit is contained in:
@@ -422,6 +422,8 @@ ByteVector Ogg::XiphComment::render(bool addFramingBit) const
|
||||
|
||||
void Ogg::XiphComment::parse(const ByteVector &data)
|
||||
{
|
||||
static constexpr unsigned int MAX_XIPH_COMMENT_FIELD_COUNT = 50000;
|
||||
|
||||
// The first thing in the comment data is the vendor ID length, followed by a
|
||||
// UTF8 string with the vendor ID.
|
||||
|
||||
@@ -438,7 +440,9 @@ void Ogg::XiphComment::parse(const ByteVector &data)
|
||||
const unsigned int commentFields = data.toUInt(pos, false);
|
||||
pos += 4;
|
||||
|
||||
if(commentFields > (data.size() - 8) / 4) {
|
||||
if(commentFields > MAX_XIPH_COMMENT_FIELD_COUNT ||
|
||||
commentFields > (data.size() - 8) / 4) {
|
||||
debug("Ogg::XiphComment::parse() - Maximum comment field count exceeded.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user