diff --git a/.gitignore b/.gitignore index 359f911..a2f8706 100644 --- a/.gitignore +++ b/.gitignore @@ -107,3 +107,4 @@ AUDIT_MASTER_PLAN.md usb_companion_probe.py CORE_MESH_AUDIT_INDEX.md UPLINK_AUDIT_INDEX.md +GPS_AUDIT_INDEX.md diff --git a/zephcore/adapters/gps/ZephyrGPSManager.cpp b/zephcore/adapters/gps/ZephyrGPSManager.cpp index 4760c6e..15dda15 100644 --- a/zephcore/adapters/gps/ZephyrGPSManager.cpp +++ b/zephcore/adapters/gps/ZephyrGPSManager.cpp @@ -1398,6 +1398,15 @@ int64_t gps_get_utc_time(void) struct gnss_time t = current_utc; k_mutex_unlock(&gps_mutex); + /* Defensive: the date math below indexes month_days[m] for m < t.month. + * t.month is a uint8_t straight from the GNSS driver — bound it (and the + * day) so a driver that doesn't range-check (the NMEA parser does; binary + * UBX/chip drivers are not all verified) can't drive an OOB read of + * month_days[13] or a garbage RTC set. */ + if (t.month < 1 || t.month > 12 || t.month_day < 1 || t.month_day > 31) { + return 0; + } + int year = 2000 + t.century_year; int days = 0;