Skip to content

Commit b135201

Browse files
committed
NTP: discard corrupted NTP response
1 parent 501271b commit b135201

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/utility/time/NTPUtils.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ unsigned long NTPUtils::getTime(UDP & udp)
6262
unsigned long const highWord = word(ntp_packet_buf[40], ntp_packet_buf[41]);
6363
unsigned long const lowWord = word(ntp_packet_buf[42], ntp_packet_buf[43]);
6464
unsigned long const secsSince1900 = highWord << 16 | lowWord;
65+
66+
/* Check for corrupted NTP response */
67+
if(secsSince1900 == 0) {
68+
return 0;
69+
}
70+
6571
unsigned long const seventyYears = 2208988800UL;
6672
unsigned long const epoch = secsSince1900 - seventyYears;
6773

0 commit comments

Comments
 (0)