summaryrefslogtreecommitdiffstats
path: root/datatrak.h
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-03 10:02:55 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-03 10:02:55 -0400
commit08db242e0e5855a4673e4caf9549bed78012737c (patch)
tree6b36755c630938e7913e65711ff714eae1dcd852 /datatrak.h
parent58fbee7150b021671d5dee70ee968fb1d42f8902 (diff)
downloadsubsurface-08db242e0e5855a4673e4caf9549bed78012737c.tar.gz
Avoid ignoring file read errors
This fixes a bunch of Coverity warnings. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'datatrak.h')
-rw-r--r--datatrak.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/datatrak.h b/datatrak.h
index 3e01c4e76..1b518ce10 100644
--- a/datatrak.h
+++ b/datatrak.h
@@ -13,22 +13,26 @@ typedef struct dtrakheader_ {
#define read_bytes(_n) \
switch (_n) { \
case 1: \
- fread (&lector_bytes, sizeof(char), _n, archivo); \
+ if (fread (&lector_bytes, sizeof(char), _n, archivo) != _n) \
+ goto bail; \
tmp_1byte = lector_bytes[0]; \
break; \
case 2: \
- fread (&lector_bytes, sizeof(char), _n, archivo); \
+ if (fread (&lector_bytes, sizeof(char), _n, archivo) != _n) \
+ goto bail; \
tmp_2bytes = two_bytes_to_int (lector_bytes[1], lector_bytes[0]); \
break; \
default: \
- fread (&lector_word, sizeof(char), _n, archivo); \
+ if (fread (&lector_word, sizeof(char), _n, archivo) != _n) \
+ goto bail; \
tmp_4bytes = four_bytes_to_long(lector_word[3], lector_word[2], lector_word[1], lector_word[0]); \
break; \
}
#define read_string(_property) \
unsigned char *_property##tmp = (unsigned char *)calloc(tmp_1byte + 1, 1); \
- fread((char *)_property##tmp, 1, tmp_1byte, archivo); \
+ if (fread((char *)_property##tmp, 1, tmp_1byte, archivo) != tmp_1byte) \
+ goto bail; \
_property = (unsigned char *)strcat(to_utf8(_property##tmp), ""); \
free(_property##tmp);