Skip to content

Commit

Permalink
CAddrMan::Deserialize handle corrupt serializations better.
Browse files Browse the repository at this point in the history
  • Loading branch information
pstratem authored and furszy committed Jul 28, 2021
1 parent d2a8baf commit e986ed0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/addrman.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,14 @@ class CAddrMan
nUBuckets ^= (1 << 30);
}

if (nNew > ADDRMAN_NEW_BUCKET_COUNT * ADDRMAN_BUCKET_SIZE) {
throw std::ios_base::failure("Corrupt CAddrMan serialization, nNew exceeds limit.");
}

if (nTried > ADDRMAN_TRIED_BUCKET_COUNT * ADDRMAN_BUCKET_SIZE) {
throw std::ios_base::failure("Corrupt CAddrMan serialization, nTried exceeds limit.");
}

// Deserialize entries from the new table.
for (int n = 0; n < nNew; n++) {
CAddrInfo& info = mapInfo[n];
Expand Down

0 comments on commit e986ed0

Please sign in to comment.