From 972b8cee400f67484055656340bee8ddc175af46 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 11 Nov 2015 15:54:14 +0100 Subject: [PATCH] CID 22436 Ignoring number of bytes read github issue #333 --- src/kernel/save.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index beda42747..fd32a567d 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1391,6 +1391,7 @@ int readgame(const char *filename, bool backup) storage store; stream strm; FILE *F; + size_t sz; init_locales(); log_debug("- reading game data from %s\n", filename); @@ -1405,8 +1406,8 @@ int readgame(const char *filename, bool backup) perror(path); return -1; } - fread(&gdata.version, sizeof(int), 1, F); - if (gdata.version >= INTPAK_VERSION) { + sz = fread(&gdata.version, sizeof(int), 1, F); + if (sz!=sizeof(int) || gdata.version >= INTPAK_VERSION) { int stream_version; size_t sz = fread(&stream_version, sizeof(int), 1, F); assert((sz==1 && stream_version == STREAM_VERSION) || !"unsupported data format");