garmin_parser: be a little less abrupt about parsing errors

Instead of returning an error on unrecognized input when parsing, just
skip to the end of the buffer.  This makes at least partially parsed
data available, which can help figure out what ended up happening.

This was part of my "Suunto also does FIT files now, and does them very
differently from Garmin" series.  I think I parse the Suunto files right
now, but next time this happens, I'd rather get partial data than no
data at all.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2023-07-13 13:49:00 -07:00
parent 3733b87ac9
commit 571df62ce5

View File

@ -1241,20 +1241,17 @@ static int traverse_regular(struct garmin_parser_t *garmin,
if (!len) {
ERROR(garmin->base.context, "field with zero length\n");
return -1;
return total_len + size;
}
if (size < len) {
ERROR(garmin->base.context, "Data traversal size bigger than remaining data (%d vs %d)\n", len, size);
return -1;
return total_len + size;
}
if (base_type > 16) {
ERROR(garmin->base.context, "Unknown base type %d\n", base_type);
data += size;
len -= size;
total_len += size;
continue;
return total_len + size;
}
base_size = base_type_info[base_type].type_size;
if (len % base_size) {