altoslib: Validate TeleMega GPS_SAT log packet nsat
authorKeith Packard <keithp@keithp.com>
Fri, 24 Jan 2014 06:16:36 +0000 (22:16 -0800)
committerKeith Packard <keithp@keithp.com>
Fri, 24 Jan 2014 06:17:40 +0000 (22:17 -0800)
Make sure nsat is not more than the size of the array

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosEepromMega.java

index 1ac72b1c4f5d65e491de6fc548d2d8238ff330ae..b8a1b9e86dc61ad09403b33c9de4ec54274a3150 100644 (file)
@@ -24,6 +24,8 @@ import java.text.*;
 public class AltosEepromMega extends AltosEeprom {
        public static final int record_length = 32;
 
 public class AltosEepromMega extends AltosEeprom {
        public static final int record_length = 32;
 
+       public static final int max_sat = 12;
+
        public int record_length() { return record_length; }
 
        /* AO_LOG_FLIGHT elements */
        public int record_length() { return record_length; }
 
        /* AO_LOG_FLIGHT elements */
@@ -176,6 +178,8 @@ public class AltosEepromMega extends AltosEeprom {
                        gps = state.make_temp_gps(true);
 
                        int n = nsat();
                        gps = state.make_temp_gps(true);
 
                        int n = nsat();
+                       if (n > max_sat)
+                               n = max_sat;
                        for (int i = 0; i < n; i++)
                                gps.add_sat(svid(i), c_n(i));
                        break;
                        for (int i = 0; i < n; i++)
                                gps.add_sat(svid(i), c_n(i));
                        break;