mpm/hs: suppress scan-build warning

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".
pull/13201/head
Victor Julien 1 year ago committed by Victor Julien
parent 19e3a70ca3
commit 61b21dd167

@ -79,7 +79,14 @@ static char *HSReadStream(const char *file_path, size_t *buffer_sz)
}
// 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));

Loading…
Cancel
Save