Skip to content

Commit

Permalink
Prevent invalid memory access on invalid signature
Browse files Browse the repository at this point in the history
  • Loading branch information
nosoop committed Sep 28, 2022
1 parent c0d399e commit 3096b79
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion types/mempatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class MemoryPatch {
for (auto bit : info.vecPreserve) {
this->vecPreserve.append(bit);
}
this->pAddress = pAddress + (info.offset);

// ignore offset if address is bad
this->pAddress = pAddress ? pAddress + (info.offset) : 0;
}

bool Enable() {
Expand Down Expand Up @@ -75,6 +77,10 @@ class MemoryPatch {
}

bool Verify() {
if (!pAddress) {
return false;
}

auto addr = (uint8_t*) pAddress;
for (size_t i = 0; i < this->vecVerify.length(); i++) {
if (vecVerify[i] != '*' && vecVerify[i] != addr[i]) {
Expand Down

0 comments on commit 3096b79

Please sign in to comment.