Skip to content

Commit

Permalink
Merge bitcoin#7932: CAddrMan::Deserialize handle corrupt serializatio…
Browse files Browse the repository at this point in the history
…ns better.

fb26bf0 CAddrMan::Deserialize handle corrupt serializations better. (Patrick Strateman)
  • Loading branch information
laanwj authored and codablock committed Dec 21, 2017
1 parent 72bee9e commit 0450dfd
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 @@ -353,6 +353,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 0450dfd

Please sign in to comment.