From 9d65c5bcddbb01e3f479397010721383df358e98 Mon Sep 17 00:00:00 2001 From: Miika Turkia Date: Sun, 7 Jan 2018 08:56:40 +0200 Subject: Stricter check we get dive profile We should get either dive trailer or dive profile immediately after header. Thus make sure that is the case. Signed-off-by: Miika Turkia --- core/import-csv.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'core/import-csv.c') diff --git a/core/import-csv.c b/core/import-csv.c index 7d46fdb76..3af424315 100644 --- a/core/import-csv.c +++ b/core/import-csv.c @@ -140,7 +140,13 @@ int parse_dan_format(const char *filename, char **params, int pnr) continue; } - ptr = strstr(ptr, "ZDP{"); + /* After ZDH we should get either ZDT (above) or ZDP */ + if (strncmp(iter, "ZDP{", 4) != 0) { + fprintf(stderr, "DEBUG: Input appears to violate DL7 specification\n"); + end_ptr = iter - (char *)mem.buffer; + continue; + } + if (ptr && ptr[4] == '}') { end_ptr += ptr - (char *)mem_csv.buffer; return report_error(translate("gettextFromC", "No dive profile found from '%s'"), filename); -- cgit v1.2.3-70-g09d2