Skip to content

Commit

Permalink
Don't try and DB Index invalid patches (#6659)
Browse files Browse the repository at this point in the history
Invalid patches (without the sub3 tag or with a ridiculous
XML size marker) skip indexing to avoid crashes.

Closes #6643
  • Loading branch information
baconpaul authored Oct 22, 2022
1 parent 81c5ee1 commit 2edea24
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/common/PatchDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,12 @@ CREATE TABLE IF NOT EXISTS Favorites (
auto *ph = (patch_header *)phd;
auto xmlSz = vt_read_int32LE(ph->xmlsize);

if (!memcpy(ph->tag, "sub3", 4) || xmlSz < 0 || xmlSz > 1024 * 1024 * 1024)
{
std::cerr << "Skipping invalid patch : [" << p.path.u8string() << "]" << std::endl;
return;
}

auto xd = phd + sizeof(patch_header);
std::string xml(xd, xd + xmlSz);

Expand Down

0 comments on commit 2edea24

Please sign in to comment.