Check for duplicates in RiffVideo::readInfoListChunk - #9369
Conversation
|
Example security report, sent by @ThureinOo: Security Advisory: Infinite Loop / CPU Exhaustion in
|
There was a problem hiding this comment.
Pull request overview
This PR optimizes RiffVideo::readInfoListChunk() by buffering INFO-list tags into a temporary associative container before updating xmpData_, aiming to reduce repeated expensive inserts and detect duplicates.
Changes:
- Collect INFO-list entries into a temporary
std::mapbefore writing toxmpData_. - Add a duplicate check/enforcement intended to reject duplicate mapped keys.
- Copy buffered entries from the temporary table into
xmpData_at the end.
Show a summary per file
| File | Description |
|---|---|
src/riffvideo.cpp |
Buffers INFO-list metadata in a temporary map, adds duplicate enforcement, then copies into xmpData_ to reduce repeated inserts. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Low
| if (auto it = Internal::infoTags.find(type); it != Internal::infoTags.end()) { | ||
| // Check that it isn't a duplicate. | ||
| Internal::enforce(table.find(it->second) == table.end(), ErrorCode::kerCorruptedMetadata); | ||
| table[it->second] = content; | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Tick the box to add this pull request to the merge queue (same as
|
We've had some security reports about
RiffVideo::readInfoListChunk()because it's a bit slow when you give it a long list to process. The complexity of this code is linear but the constant factor cost of inserting an element intoxmpData_is high. I got a 4x speedup by copying the elements into astd::mapfirst (to eliminate duplicate keys). But duplicate keys probably only happen in malformed input files, so I've also added anenforceto disallow duplicates.I don't think this is a security issue because it's just slow performance. It's not a quadratic algorithm, just constant factor slowness.