qcomgpsd, timed: reject invalid GPS timestamps (#37633)

This commit is contained in:
Adeeb Shihadeh
2026-03-10 11:44:25 -07:00
committed by GitHub
parent 9164148d48
commit bf4bf0e5b7
3 changed files with 7 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ import datetime
from pathlib import Path
MIN_DATE = datetime.datetime(year=2025, month=2, day=21)
MAX_DATE = datetime.datetime(year=2035, month=1, day=1)
def min_date():
# on systemd systems, the default time is the systemd build time
@@ -12,4 +13,4 @@ def min_date():
return MIN_DATE
def system_time_valid():
return datetime.datetime.now() > min_date()
return min_date() < datetime.datetime.now() < MAX_DATE

View File

@@ -357,6 +357,9 @@ def main() -> NoReturn:
report = unpack_position(log_payload)
if report["u_PosSource"] != 2:
continue
# uint16_t max is an invalid sentinel value from the modem
if report['w_GpsWeekNumber'] >= 0xFFFF:
continue
vNED = [report["q_FltVelEnuMps[1]"], report["q_FltVelEnuMps[0]"], -report["q_FltVelEnuMps[2]"]]
vNEDsigma = [report["q_FltVelSigmaMps[1]"], report["q_FltVelSigmaMps[0]"], -report["q_FltVelSigmaMps[2]"]]

View File

@@ -5,7 +5,7 @@ import time
from typing import NoReturn
import cereal.messaging as messaging
from openpilot.common.time_helpers import min_date, system_time_valid
from openpilot.common.time_helpers import min_date, MAX_DATE, system_time_valid
from openpilot.common.swaglog import cloudlog
from openpilot.common.params import Params
from openpilot.common.gps import get_gps_location_service
@@ -52,7 +52,7 @@ def main() -> NoReturn:
continue
if not gps.hasFix:
continue
if gps_time < min_date():
if gps_time < min_date() or gps_time > MAX_DATE:
continue
set_time(gps_time)