CAddrMan::Deserialize handle corrupt serializations better.

Signed-off-by: Simon <simon@bitcartel.com>
This commit is contained in:
Patrick Strateman 2016-04-23 22:21:52 -07:00 committed by Simon
parent 1bf2cb1a06
commit 7bfb552f63
1 changed files with 8 additions and 0 deletions

View File

@ -349,6 +349,14 @@ public:
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];