From 7891db986147c3106e8366aea2499bb00c32821a Mon Sep 17 00:00:00 2001 From: User Date: Tue, 1 Dec 2015 15:57:24 +0100 Subject: [PATCH] Add more checks for ferror() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Malý --- libhpcs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libhpcs.c b/libhpcs.c index 655fca7..896e114 100644 --- a/libhpcs.c +++ b/libhpcs.c @@ -844,6 +844,8 @@ static enum HPCS_ParseCode read_signal(FILE* datafile, struct HPCS_TVPair** pair fseek(datafile, DATA_OFFSET_DATA_START, SEEK_SET); if (feof(datafile)) return PARSE_E_OUT_OF_RANGE; + if (ferror(datafile)) + return PARSE_E_CANT_READ; r = fread(raw, SEGMENT_SIZE, 1, datafile); if (r != 1) @@ -955,6 +957,8 @@ static enum HPCS_ParseCode read_sampling_rate(FILE* datafile, double* sampling_r fseek(datafile, DATA_OFFSET_SAMPLING_RATE, SEEK_SET); if (feof(datafile)) return PARSE_E_OUT_OF_RANGE; + if (ferror(datafile)) + return PARSE_E_CANT_READ; r = fread(raw, SEGMENT_SIZE, 1, datafile); if (r != 1) @@ -977,6 +981,8 @@ static enum HPCS_ParseCode read_string_at_offset(FILE* datafile, const HPCS_offs fseek(datafile, offset, SEEK_SET); if (feof(datafile)) return PARSE_E_OUT_OF_RANGE; + if (ferror(datafile)) + return PARSE_E_CANT_READ; r = fread(&str_length, SMALL_SEGMENT_SIZE, 1, datafile); if (r != 1) -- 2.43.5