From 04c367fd06454bf834f477e7987ba0a54d99741b Mon Sep 17 00:00:00 2001 From: Janice McLaughlin Date: Tue, 2 Oct 2018 16:03:36 -0700 Subject: [PATCH] Oceanic: fix up dive truncation issues This fixes the dive truncation that happened with long dives due to the removal of extra padding (commit a2100843b9cf: "Remove extra padding from the end of the profile"). It turns out the rest of the profile was in bits 13-15 (with bit 12 being something else). --- src/oceanic_common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/oceanic_common.c b/src/oceanic_common.c index 184e5f9..bdc2f79 100644 --- a/src/oceanic_common.c +++ b/src/oceanic_common.c @@ -499,7 +499,10 @@ oceanic_common_device_profile (dc_device_t *abstract, dc_event_progress_t *progr // The logbook entry contains the total number of pages containing // profile data, excluding the footer page. Limit the profile size // to this size. - unsigned int npages = (array_uint16_le (profiles + offset + 12) & 0x0FFF) + 1; + unsigned int value = array_uint16_le (profiles + offset + 12); + unsigned int value_hi = value & 0xE000; + unsigned int value_lo = value & 0x0FFF; + unsigned int npages = ((value_hi >> 1) | value_lo) + 1; unsigned int length = npages * PAGESIZE; if (rb_entry_size > length) { rb_entry_size = length;