mirror of
https://github.com/liquidraver/ZephCore.git
synced 2026-09-01 22:08:19 +00:00
guard GPS month_days[] index against out-of-range GNSS month (gps audit)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user