util-mpm-hs-cache.c:83:25: warning: Value of 'errno' was not checked and may be overwritten by function 'fread' [unix.Errno]
83 | size_t bytes_read = fread(buffer, 1, file_sz, file);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
"After calling 'rewind' reading 'errno' is required to find out if the call has failed".
}
// Rewind file pointer and read the file into the buffer
+ errno = 0;
rewind(file);
+ if (errno != 0) {
+ SCLogDebug("Failed to rewind file %s: %s", file_path, strerror(errno));
+ SCFree(buffer);
+ fclose(file);
+ return NULL;
+ }
size_t bytes_read = fread(buffer, 1, file_sz, file);
if (bytes_read != (size_t)file_sz) {
SCLogDebug("Failed to read the entire file %s: %s", file_path, strerror(errno));