mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Safeguards for Liquivision import
I have received one sample log where after parsing a bunch of dives properly, the sample count hits zero, and after that it is astronomical. In case of zero, the only data we have is dive date and time of a duplicate dive that we already parsed with proper dive profile. So preventing a crash with this hack without properly understanding the weird file format. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
This commit is contained in:
parent
1b0812a8cb
commit
e78f89b0d8
1 changed files with 9 additions and 0 deletions
|
@ -278,6 +278,15 @@ static void parse_dives (int log_version, const unsigned char *buf, unsigned int
|
|||
algorithm = *(buf + ptr++); // 0=ZH-L16C+GF
|
||||
sample_count = array_uint32_le(buf + ptr);
|
||||
}
|
||||
|
||||
if (sample_count == 0) {
|
||||
fprintf(stderr, "DEBUG: sample count 0 - terminating parser\n");
|
||||
break;
|
||||
}
|
||||
if (ptr + sample_count * 4 + 4 > buf_size) {
|
||||
fprintf(stderr, "DEBUG: BOF - terminating parser\n");
|
||||
break;
|
||||
}
|
||||
// we aren't using the start_cns, dive_mode, and algorithm, yet
|
||||
(void)start_cns;
|
||||
(void)dive_mode;
|
||||
|
|
Loading…
Add table
Reference in a new issue