Skip to content

Commit

Permalink
Fix ENGINE_OPTIONS_FORCE_TO_DISK scan performance
Browse files Browse the repository at this point in the history
There is a scan logic issue where the main libclamav scanning functions
create an extra "nested" fmap for each file being scanned. This is
slightly inefficient for a normal scan, but causes a major performance
issue when using ENGINE_OPTIONS_FORCE_TO_DISK. It causes every scanned
file to be duplicated in the temp directory before the scan.

We fix this by using `cli_magic_scan()` in `scan_common()` instead
of `cli_magic_scan_nested_fmap_type()`. We can do this now that the
`cl_scandesc_callback()` API creates an fmap for the caller, instead of
the old logic where `scan_common()` called different API's depending on
whether or not we have an fmap or a file descriptor.
  • Loading branch information
micahsnyder committed May 18, 2021
1 parent fe96de8 commit 1919141
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libclamav/scanners.c
Original file line number Diff line number Diff line change
Expand Up @@ -4874,7 +4874,7 @@ static cl_error_t scan_common(cl_fmap_t *map, const char *filepath, const char *

cli_logg_setup(&ctx);

rc = cli_magic_scan_nested_fmap_type(map, 0, map->len, &ctx, CL_TYPE_ANY, target_basename);
rc = cli_magic_scan(&ctx, CL_TYPE_ANY);

if (rc == CL_CLEAN && ctx.found_possibly_unwanted) {
cli_virus_found_cb(&ctx);
Expand Down

0 comments on commit 1919141

Please sign in to comment.