Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/src/garmin_fit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ List<FitMessage> parseFit(List<int> bytes) {
out.add(msg);
i = next;
if (ts != null) lastTs = ts;
if (i > end) throw const FormatException('FIT: record overruns data');
continue;
}
final local = h & 0x0f;
Expand Down
9 changes: 9 additions & 0 deletions test/garmin_fit_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ void main() {
expect(() => parseFit(bad), throwsFormatException);
});

test('a compressed record that overruns the data is refused too', () {
final good = (FitWriter()
..define(0, kFitMsgMonitoring, [(253, 4, 0x86)])
..compressed(0, 1, u32(1)))
.build();
final bad = Uint8List.fromList(good)..[4] = good[4] - 2;
expect(() => parseFit(bad), throwsFormatException);
});

test('a timestamp that is not a single integer is a FormatException', () {
List<int> fit(int global, int field, int size, int base, List<int> bytes) =>
(FitWriter()
Expand Down
Loading