From dc714e582f591d26ef08004fbe904b4868462d73 Mon Sep 17 00:00:00 2001 From: Jan Mulder Date: Thu, 28 Dec 2017 22:01:16 +0100 Subject: [PATCH] cleanup: Unchecked return value from library CID 60227 Signed-off-by: Jan Mulder --- core/ostctools.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/core/ostctools.c b/core/ostctools.c index e56b50f5d..53dab4aaa 100644 --- a/core/ostctools.c +++ b/core/ostctools.c @@ -57,7 +57,12 @@ void ostctools_import(const char *file, struct dive_table *divetable) // Read dive number from the log uc_tmp = calloc(2, 1); - fseek(archive, 258, 0); + if (fseek(archive, 258, 0) == -1) { + report_error(failed_to_read_msg, file); + free(uc_tmp); + free(ostcdive); + goto close_out; + } if (fread(uc_tmp, 1, 2, archive) != 2) { report_error(failed_to_read_msg, file); free(uc_tmp); @@ -69,7 +74,12 @@ void ostctools_import(const char *file, struct dive_table *divetable) // Read device's serial number uc_tmp = calloc(2, 1); - fseek(archive, 265, 0); + if (fseek(archive, 265, 0) == -1) { + report_error(failed_to_read_msg, file); + free(uc_tmp); + free(ostcdive); + goto close_out; + } if (fread(uc_tmp, 1, 2, archive) != 2) { report_error(failed_to_read_msg, file); free(uc_tmp); @@ -80,7 +90,12 @@ void ostctools_import(const char *file, struct dive_table *divetable) free(uc_tmp); // Read dive's raw data, header + profile - fseek(archive, 456, 0); + if (fseek(archive, 456, 0) == -1) { + report_error(failed_to_read_msg, file); + free(uc_tmp); + free(ostcdive); + goto close_out; + } while ((c = getc(archive)) != EOF) { buffer[i] = c; if (buffer[i] == 0xFD && buffer[i - 1] == 0xFD)