Descent3/cfile
Jason Yundt d5e893fcb4 Prevent potential uninitialized memory access
Before this change, cf_OpenLibrary() did something along the lines of
this:

  char id[4];
  fread(id, 4, 1, fp);
  strncmp(id, "HOG2", 4);

If fread() finishes successfully, then that code is fine. However,
fread() might encounter an error or bump into the end of a file. In
those scenarios, the value of id will not necessarily be initialized
[1]. In other words, when fread() fails, strncmp() might operate on
uninitialized memory.

This change makes sure that the value of id only gets used if fread()
succeeds. Additionally, this change fixes a GCC warning about ignoring
fread()’s return value.

[1]: <https://en.cppreference.com/w/cpp/io/c/fread>
2024-05-12 20:38:35 -04:00
..
cfile.cpp Prevent potential uninitialized memory access 2024-05-12 20:38:35 -04:00
cfile.h Do not attempt case-sensitive processing on Windows 2024-05-06 19:08:31 +01:00
CMakeLists.txt Add BUILD_INTERFACE to cfile module 2024-04-24 00:41:02 +03:00
hogfile.cpp Join license header with historical commentrs 2024-05-08 14:41:19 -04:00
hogfile.h Stop using hard coded value for HOG2 id length 2024-05-12 20:38:32 -04:00
inffile.cpp Add BUILD_INTERFACE to cfile module 2024-04-24 00:41:02 +03:00
inffile.h Reapply "Cfile module update" 2024-04-24 00:40:39 +03:00