]> Devoid-pointer.net GitWeb - libHPCS.git/commitdiff
Add more checks for ferror()
authorUser <User>
Tue, 1 Dec 2015 14:57:24 +0000 (15:57 +0100)
committerMichal Malý <madcatxster@devoid-pointer.net>
Tue, 1 Dec 2015 17:00:45 +0000 (18:00 +0100)
Signed-off-by: Michal Malý <madcatxster@devoid-pointer.net>
libhpcs.c

index 655fca7c754b2194fa9d2d402d9b45f8df8ff3c7..896e1146969daab7bee0827048a9ed2d19d7339a 100644 (file)
--- 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)