From 80f5c7025e110a2c4f1e9eda5f7c62f3a558948e Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sat, 2 Jun 2012 09:27:01 +0200 Subject: [PATCH] Fix the detection of the last dive. It looks like the Icon HD erases old dives partially with 0xFF bytes before overwriting them with new dives. If the head of the oldest dive has been erased, the length field which is stored in the first 4 bytes is erased as well, and we can use it to detect the last dive. --- src/mares_iconhd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mares_iconhd.c b/src/mares_iconhd.c index 9ac25d7..6fb10c2 100644 --- a/src/mares_iconhd.c +++ b/src/mares_iconhd.c @@ -441,7 +441,7 @@ mares_iconhd_extract_dives (device_t *abstract, const unsigned char data[], unsi // equals the calculated length. If both values are different, // something is wrong and an error is returned. unsigned int length = array_uint32_le (buffer + offset); - if (length == 0) + if (length == 0 || length == 0xFFFFFFFF) break; if (length != nbytes) { WARNING ("Calculated and stored size are not equal.");