From: User Date: Tue, 1 Dec 2015 14:57:24 +0000 (+0100) Subject: Add more checks for ferror() X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=7891db986147c3106e8366aea2499bb00c32821a;p=libHPCS.git Add more checks for ferror() Signed-off-by: Michal MalĂ˝ --- 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)