Code quality: Refactor layer attributes as scan parameter

The current implementation sets a "next layer attributes" flag field
in the scan context. This may introduce bugs if accidentally not cleared
during error handling, causing that attribute to be applied to a
different layer than intended.

This commit resolves that by adding an attribute flag to the major
internal scan functions and removing the "next layer attributes" from
the scan context. This attributes flag shares the same flag fields as
the attributes flag in the new file inspection callback and the flags
are defined in `clamav.h`.
This commit is contained in:
Micah Snyder 2022-03-09 22:26:40 -08:00 committed by Micah Snyder
parent c7c4ea6063
commit cd3134568a
45 changed files with 298 additions and 275 deletions

View file

@ -1723,7 +1723,7 @@ int cli_scan_ole10(int fd, cli_ctx *ctx)
cli_dbgmsg("cli_decode_ole_object: decoding to %s\n", fullname);
ole_copy_file_data(fd, ofd, object_size);
lseek(ofd, 0, SEEK_SET);
ret = cli_magic_scan_desc(ofd, fullname, ctx, NULL);
ret = cli_magic_scan_desc(ofd, fullname, ctx, NULL, LAYER_ATTRIBUTES_NONE);
close(ofd);
if (ctx && !ctx->engine->keeptmp)
if (cli_unlink(fullname))