Missing GPS serial data could cause the tracking array reset to
get skipped, causing the array to be overrun, smashing critical data
beyond the array.
This was detected using the 'altosui' flash command to program a
device from TM. Hitting the USB that hard caused TM to crash with a
mutex error (3 beeps) after the ao_gps_task structure was overwritten
with zeros.
Signed-off-by: Keith Packard <keithp@keithp.com>
+#define AO_MAX_GPS_TRACKING 12
+
struct ao_gps_tracking_data {
uint8_t channels;
struct ao_gps_tracking_data {
uint8_t channels;
- struct ao_gps_sat_data sats[12];
+ struct ao_gps_sat_data sats[AO_MAX_GPS_TRACKING];
};
extern __xdata uint8_t ao_gps_mutex;
};
extern __xdata uint8_t ao_gps_mutex;
ao_gps_skip_field(); /* sats in view */
while (ao_gps_char != '*' && ao_gps_char != '\n' && ao_gps_char != '\r') {
i = ao_gps_tracking_next.channels;
ao_gps_skip_field(); /* sats in view */
while (ao_gps_char != '*' && ao_gps_char != '\n' && ao_gps_char != '\r') {
i = ao_gps_tracking_next.channels;
- ao_gps_tracking_next.sats[i].svid = ao_gps_decimal(2); /* SVID */
+ c = ao_gps_decimal(2); /* SVID */
+ if (i < AO_MAX_GPS_TRACKING)
+ ao_gps_tracking_next.sats[i].svid = c;
ao_gps_lexchar();
ao_gps_skip_field(); /* elevation */
ao_gps_lexchar();
ao_gps_skip_field(); /* azimuth */
ao_gps_lexchar();
ao_gps_skip_field(); /* elevation */
ao_gps_lexchar();
ao_gps_skip_field(); /* azimuth */
- if (!(ao_gps_tracking_next.sats[i].c_n_1 = ao_gps_decimal(2))) /* C/N0 */
- ao_gps_tracking_next.sats[i].svid = 0;
- ao_gps_tracking_next.channels = i + 1;
+ c = ao_gps_decimal(2); /* C/N0 */
+ if (i < AO_MAX_GPS_TRACKING) {
+ if (!(ao_gps_tracking_next.sats[i].c_n_1 = c))
+ ao_gps_tracking_next.sats[i].svid = 0;
+ ao_gps_tracking_next.channels = i + 1;
+ }
}
if (ao_gps_char == '*') {
uint8_t cksum = ao_gps_cksum ^ '*';
}
if (ao_gps_char == '*') {
uint8_t cksum = ao_gps_cksum ^ '*';
+#define AO_MAX_GPS_TRACKING 12
+
struct ao_gps_tracking_data {
uint8_t channels;
struct ao_gps_tracking_data {
uint8_t channels;
- struct ao_gps_sat_data sats[12];
+ struct ao_gps_sat_data sats[AO_MAX_GPS_TRACKING];
+#define AO_MAX_GPS_TRACKING 12
+
struct ao_gps_tracking_data {
uint8_t channels;
struct ao_gps_tracking_data {
uint8_t channels;
- struct ao_gps_sat_data sats[12];
+ struct ao_gps_sat_data sats[AO_MAX_GPS_TRACKING];