p2p: Don't use timestamps from inbound peers

This makes it harder for others to tamper with
our adjusted time.
This commit is contained in:
Martin Zumsande 2021-11-29 16:33:00 +01:00
parent a574f4ad39
commit 0c85dc30e6

View file

@ -2683,7 +2683,11 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
int64_t nTimeOffset = nTime - GetTime();
pfrom.nTimeOffset = nTimeOffset;
AddTimeData(pfrom.addr, nTimeOffset);
if (!pfrom.IsInboundConn()) {
// Don't use timedata samples from inbound peers to make it
// harder for others to tamper with our adjusted time.
AddTimeData(pfrom.addr, nTimeOffset);
}
// If the peer is old enough to have the old alert system, send it the final alert.
if (greatest_common_version <= 70012) {