From: Victor Julien Date: Wed, 7 May 2025 18:51:48 +0000 (+0200) Subject: mpm/hs: suppress scan-build warning X-Git-Tag: suricata-8.0.0-rc1~327 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=61b21dd167e27cf7584a143ed8ac3af4e9124125;p=thirdparty%2Fsuricata.git 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". --- diff --git a/src/util-mpm-hs-cache.c b/src/util-mpm-hs-cache.c index 5b91c0197b..75cdee2171 100644 --- a/src/util-mpm-hs-cache.c +++ b/src/util-mpm-hs-cache.c @@ -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));