From 3a6206e72c6a23053c181f7745dabb94b5936b9b Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 10 Apr 2015 22:31:29 +0200 Subject: [PATCH] Relax the detection of the last dive. We received data from a Mares Smart where the existing heuristics to detect the last dive are not sufficient. The very last check, where the calculated and stored are compared results in a fatal error. --- src/mares_iconhd.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/mares_iconhd.c b/src/mares_iconhd.c index 48bf561..7f774cc 100644 --- a/src/mares_iconhd.c +++ b/src/mares_iconhd.c @@ -538,15 +538,10 @@ mares_iconhd_extract_dives (dc_device_t *abstract, const unsigned char data[], u // Verify that the length that is stored in the profile data // equals the calculated length. If both values are different, - // something is wrong and an error is returned. + // we assume we reached the last dive. unsigned int length = array_uint32_le (buffer + offset); - if (length == 0 || length == 0xFFFFFFFF) + if (length != nbytes) break; - if (length != nbytes) { - ERROR (context, "Calculated and stored size are not equal."); - free (buffer); - return DC_STATUS_DATAFORMAT; - } unsigned char *fp = buffer + offset + length - headersize + fingerprint; if (device && memcmp (fp, device->fingerprint, sizeof (device->fingerprint)) == 0) {