@@ -452,7 +452,7 @@ struct field_desc {
452
452
{ \
453
453
char fmtbuf[FMTSIZE]; \
454
454
if (strcmp(#type, base_type_info[base_type].type_name)) \
455
- fprintf(stderr , "%s: %s should be %s\n", #name, #type, base_type_info[base_type].type_name); \
455
+ WARNING(g->base.context , "%s: %s should be %s\n", #name, #type, base_type_info[base_type].type_name); \
456
456
type val = type##_VALUE(g, p); \
457
457
if (val == type##_INVAL) return; \
458
458
type##_FORMAT(val, fmtbuf); \
@@ -1499,29 +1499,25 @@ traverse_data(struct garmin_parser_t *garmin)
1499
1499
memset (& garmin -> record_data , 0 , sizeof (garmin -> record_data ));
1500
1500
memset (garmin -> type_desc , 0 , sizeof (garmin -> type_desc ));
1501
1501
1502
- // The data starts with our filename fingerprint. Skip it.
1503
- if (len < FIT_NAME_SIZE )
1504
- return DC_STATUS_IO ;
1505
-
1506
- DEBUG (garmin -> base .context , "file %.*s" , FIT_NAME_SIZE , data );
1507
-
1508
- data += FIT_NAME_SIZE ;
1509
- len -= FIT_NAME_SIZE ;
1510
-
1511
1502
// The FIT header
1512
- if (len < 12 )
1503
+ if (len < 12 ) {
1504
+ ERROR (garmin -> base .context , " file too short for FIT header" );
1505
+
1513
1506
return DC_STATUS_IO ;
1507
+ }
1514
1508
1515
1509
hdrsize = data [0 ];
1516
1510
protocol = data [1 ];
1517
1511
profile = array_uint16_le (data + 2 ); // these two fields are always little endian
1518
1512
datasize = array_uint32_le (data + 4 );
1519
1513
if (memcmp (data + 8 , ".FIT" , 4 )) {
1520
- DEBUG (garmin -> base .context , " missing .FIT marker" );
1514
+ ERROR (garmin -> base .context , " missing .FIT marker" );
1515
+
1521
1516
return DC_STATUS_IO ;
1522
1517
}
1523
1518
if (hdrsize < 12 || datasize > len || datasize + hdrsize + 2 > len ) {
1524
- DEBUG (garmin -> base .context , " inconsistent size information hdrsize %d datasize %d len %d" , hdrsize , datasize , len );
1519
+ ERROR (garmin -> base .context , " inconsistent size information hdrsize %d datasize %d len %d" , hdrsize , datasize , len );
1520
+
1525
1521
return DC_STATUS_IO ;
1526
1522
}
1527
1523
garmin -> dive .protocol = protocol ;
@@ -1563,8 +1559,11 @@ traverse_data(struct garmin_parser_t *garmin)
1563
1559
DEBUG (garmin -> base .context , "Regular record for type %d" , record );
1564
1560
len = traverse_regular (garmin , data , datasize , record , & time );
1565
1561
}
1566
- if (len <= 0 || len > datasize )
1562
+ if (len <= 0 || len > datasize ) {
1563
+ ERROR (garmin -> base .context , " traverse failed" );
1564
+
1567
1565
return DC_STATUS_IO ;
1566
+ }
1568
1567
data += len ;
1569
1568
datasize -= len ;
1570
1569
0 commit comments