diff options
author | Martin Zumsande <mzumsande@gmail.com> | 2021-11-29 16:33:00 +0100 |
---|---|---|
committer | Martin Zumsande <mzumsande@gmail.com> | 2021-11-29 16:46:41 +0100 |
commit | 0c85dc30e6b628f7538a67776c7eefcb84ef4f82 (patch) | |
tree | 529b0ad1caf22e17c8f8d107d18b5893c136697b /src/net_processing.cpp | |
parent | a574f4ad390908ace794eb10fdb917d66c57094b (diff) |
p2p: Don't use timestamps from inbound peers
This makes it harder for others to tamper with
our adjusted time.
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r-- | src/net_processing.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index a896bb76ae..ebabba5c78 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -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) { |