CID 22436 Ignoring number of bytes read

github issue #333
This commit is contained in:
Enno Rehling 2015-11-11 15:54:14 +01:00
parent 1949e8710d
commit 972b8cee40
1 changed files with 3 additions and 2 deletions

View File

@ -1391,6 +1391,7 @@ int readgame(const char *filename, bool backup)
storage store; storage store;
stream strm; stream strm;
FILE *F; FILE *F;
size_t sz;
init_locales(); init_locales();
log_debug("- reading game data from %s\n", filename); log_debug("- reading game data from %s\n", filename);
@ -1405,8 +1406,8 @@ int readgame(const char *filename, bool backup)
perror(path); perror(path);
return -1; return -1;
} }
fread(&gdata.version, sizeof(int), 1, F); sz = fread(&gdata.version, sizeof(int), 1, F);
if (gdata.version >= INTPAK_VERSION) { if (sz!=sizeof(int) || gdata.version >= INTPAK_VERSION) {
int stream_version; int stream_version;
size_t sz = fread(&stream_version, sizeof(int), 1, F); size_t sz = fread(&stream_version, sizeof(int), 1, F);
assert((sz==1 && stream_version == STREAM_VERSION) || !"unsupported data format"); assert((sz==1 && stream_version == STREAM_VERSION) || !"unsupported data format");