aboutsummaryrefslogtreecommitdiff
path: root/src/db.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/db.cpp')
-rw-r--r--src/db.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/db.cpp b/src/db.cpp
index 867703fbd2..278c82078a 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -842,20 +842,22 @@ bool CAddrDB::Read(CAddrMan& addr)
if (hashIn != hashTmp)
return error("CAddrman::Read() : checksum mismatch; data corrupted");
- // de-serialize address data
unsigned char pchMsgTmp[4];
try {
+ // de-serialize file header (pchMessageStart magic number) and
ssPeers >> FLATDATA(pchMsgTmp);
+
+ // verify the network matches ours
+ if (memcmp(pchMsgTmp, pchMessageStart, sizeof(pchMsgTmp)))
+ return error("CAddrman::Read() : invalid network magic number");
+
+ // de-serialize address data into one CAddrMan object
ssPeers >> addr;
}
catch (std::exception &e) {
return error("CAddrman::Read() : I/O error or stream data corrupted");
}
- // finally, verify the network matches ours
- if (memcmp(pchMsgTmp, pchMessageStart, sizeof(pchMsgTmp)))
- return error("CAddrman::Read() : invalid network magic number");
-
return true;
}