Changeset a5ca936 for router


Ignore:
Timestamp:
Feb 19, 2018 2:25:57 PM (3 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
646fe20
Parents:
826d8ca
Message:

more NTP response sanity checks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/time/NtpClient.java

    r826d8ca ra5ca936  
    235235            }
    236236
     237            // More sanity checks
     238            // See http://doolittle.icarus.com/ntpclient/README
     239            // See RFC 4330 Sec. 5
     240            if (msg.leapIndicator == 3 ||
     241                msg.version < 3 ||
     242                // 4 for server. Above reference is wrong, it says 3 which is client.
     243                msg.mode != 4 ||
     244                msg.transmitTimestamp <= 0 ||
     245                // following values are in seconds, vs. 1/65536 seconds in above reference
     246                Math.abs(msg.rootDelay) > 1.0d ||
     247                Math.abs(msg.rootDispersion) > 1.0d) {
     248                if (log != null && log.shouldWarn())
     249                    log.warn("Failed sanity checks:\n" + msg);
     250                return null;
     251            }
     252
    237253            // KoD check (AFTER spoof checks)
    238254            if (msg.stratum == 0) {
Note: See TracChangeset for help on using the changeset viewer.