libclamav: Fix issue scanning with no signatures loaded (#1560)

If the application never calls `cl_load()`, then the clean-cache is
never initialized. That is a legitimate mode to run in when perhaps we
just want to extract stuff, record metadata, or for fuzzing.

This commit adds a check if the ctx->engine->cache is NULL. If it is,
then we treat it as though caching is disabled.

CLAM-2856
This commit is contained in:
Val S. 2025-08-28 10:31:35 -04:00 committed by GitHub
parent 9198f411d5
commit c11ac06e0e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4608,7 +4608,13 @@ cl_error_t cli_magic_scan(cli_ctx *ctx, cli_file_t type)
typercg = 0;
}
if (ctx->engine->engine_options & ENGINE_OPTIONS_DISABLE_CACHE) {
/*
* Determine if caching is enabled.
* The application may have specifically disabled caching. Also, if the application never loaded any signatures,
* then the cache will be NULL and caching will also be disabled.
*/
if ((ctx->engine->engine_options & ENGINE_OPTIONS_DISABLE_CACHE) ||
(ctx->engine->cache == NULL)) {
cache_enabled = false;
}