arduino-libraries / NTPClient

Connect to a NTP server
542 stars 372 forks source link

Add packet validity checks #145

Open bmcdonnell opened 3 years ago

bmcdonnell commented 3 years ago

Addresses #133. Improves upon #28 (not merged).

CLAassistant commented 3 years ago

CLA assistant check
All committers have signed the CLA.

github-actions[bot] commented 3 years ago

Memory usage change @ cb073babecbc55eb10100a87824e339a5ce5db4e

Board flash % RAM for global variables %
esp8266:esp8266:huzzah :small_red_triangle: +112 - +112 +0.01 - +0.01 0 - 0 0.0 - 0.0
Click for full report table Board|examples/Advanced
flash|%|examples/Advanced
RAM for global variables|%|examples/Basic
flash|%|examples/Basic
RAM for global variables|% -|-|-|-|-|-|-|-|- esp8266:esp8266:huzzah|112|0.01|0|0.0|112|0.01|0|0.0
Click for full report CSV ``` Board,examples/Advanced
flash,%,examples/Advanced
RAM for global variables,%,examples/Basic
flash,%,examples/Basic
RAM for global variables,% esp8266:esp8266:huzzah,112,0.01,0,0.0,112,0.01,0,0.0 ```
bmcdonnell commented 3 years ago

I added a check of the fractional part of the reference time, since per RFC4330,

There will exist a 232-picosecond interval, henceforth ignored, every 136 years when the 64-bit field will be 0, which by convention is interpreted as an invalid or unavailable timestamp.

This time does roll over, so it can hit zero again. The reference time isn't updated frequently - it's not always getting updated in subsequent queries like the other timestamps - so this force push covers a very rare but still conceivable corner case (vs the previous revision).

bmcdonnell commented 3 years ago

Marked as draft because I'm getting some NTP version 3 responses, which this was rejecting.

github-actions[bot] commented 3 years ago

Memory usage change @ 38a7dffd324d3695b334ddc59cbaa8680b124ee0

Board flash % RAM for global variables %
esp8266:esp8266:huzzah :small_red_triangle: +160 - +160 +0.02 - +0.02 0 - 0 0.0 - 0.0
Click for full report table Board|examples/Advanced
flash|%|examples/Advanced
RAM for global variables|%|examples/Basic
flash|%|examples/Basic
RAM for global variables|% -|-|-|-|-|-|-|-|- esp8266:esp8266:huzzah|160|0.02|0|0.0|160|0.02|0|0.0
Click for full report CSV ``` Board,examples/Advanced
flash,%,examples/Advanced
RAM for global variables,%,examples/Basic
flash,%,examples/Basic
RAM for global variables,% esp8266:esp8266:huzzah,160,0.02,0,0.0,160,0.02,0,0.0 ```