Skip to content

ntptime: Reject Kiss-o-Death and zero timestamps. - #1152

Merged
dpgeorge merged 1 commit into
micropython:masterfrom
pablogventura:ntptime-kod-response
Sep 14, 2026
Merged

ntptime: Reject Kiss-o-Death and zero timestamps.#1152
dpgeorge merged 1 commit into
micropython:masterfrom
pablogventura:ntptime-kod-response

Conversation

@pablogventura

Copy link
Copy Markdown
Contributor

Summary

Test plan

  • micropython/net/ntptime/test_ntptime.py: valid reply now uses stratum 2; added KoD (stratum 0) and zero timestamp cases.

Trade-offs and Alternatives

  • Did not change settime() to return bool (would break existing callers).
  • Did not change the default socket timeout.

ntptime.mpy (mpy-cross, compiled as ntptime.py):

Version bytes vs master
master 563 -
#1151 (previous on this branch) 600 +37
this commit 620 +57

Delta vs #1151: +20.

@pablogventura

Copy link
Copy Markdown
Contributor Author

Follow-up: same OSError(-1) for stratum 0 or timestamp 0, written as if not (msg[1] and val).

ntptime.mpy (mpy-cross, compiled as ntptime.py):

Version bytes vs master
master 563 -
previous on this branch 620 +57
this commit 616 +53

@pablogventura

Copy link
Copy Markdown
Contributor Author

Rebased onto updated #1151 (dropped recvfrom() source check; short-reply validation still uses recv(48)). KoD / zero-timestamp rejection unchanged.

ntptime.mpy (mpy-cross, compiled as ntptime.py):

Version bytes vs master
master 563 -
previous on this branch 616 +53
this tip (on #1151) 600 +37

@dpgeorge

Copy link
Copy Markdown
Member

Please rebase on latest master.

@pablogventura

pablogventura commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto latest master (with #1151 merged). Only the Kiss-o-Death / zero-timestamp commits remain on top.

ntptime.mpy (mpy-cross, compiled as ntptime.py):

Version bytes vs master
master 584 -
previous on this branch 600 +16
this tip 600 +16

Fixes issue micropython#604: a Kiss-o-Death reply (stratum 0) or a zero transmit
timestamp was accepted.  The Y2036 wrap then turned val == 0 into a fake
2036 time, and settime() could apply it.

Signed-off-by: Pablo Ventura <pablogventura@gmail.com>
@dpgeorge
dpgeorge force-pushed the ntptime-kod-response branch from d258999 to 5139530 Compare September 14, 2026 00:10
@dpgeorge
dpgeorge merged commit 5139530 into micropython:master Sep 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ntptime: Does not handle KoD (Kiss of Death) resonse.

2 participants