mirror of https://github.com/lumapu/ahoy.git
Browse Source
handleNTPPacket() memcpy'd 80 bytes from packet.data() unconditionally, over-reading the stack when a short or garbage UDP datagram arrives (NTP responses are 48 bytes). The derived epoch was applied without any sanity check — a corrupt packet silently sets an arbitrary system time, which drives sunrise/sunset communication windows and scheduled reboots. Changes: - Reject packets shorter than 48 bytes (NTP_PACKET_SIZE) before reading - Reduce buffer to NTP_PACKET_SIZE and copy only the needed bytes - Validate NTP timestamp >= 3786825600 (2020-01-01 in NTP era) to reject corrupt values and prevent unsigned underflow in epoch subtraction - On rejection, return early without clearing the NTP timeout so the existing retry mechanism fires naturally (no stall) Lower bound rationale: 3786825600 is 2020-01-01 expressed in NTP seconds (seconds since 1900). This is well before any ahoy firmware release; any NTP time before this is unambiguously corrupt. Checking secsSince1900 directly (rather than the derived epoch) also prevents unsigned underflow when secsSince1900 < 2208988800 (the Unix epoch offset).pull/1889/head
1 changed files with 18 additions and 4 deletions
Loading…
Reference in new issue