PDF : make matcher check for pdf phash

libclamav/matcher : check for CL_TYPE_PDF to match image hash
libclamav/scanners: change place of calculate_fuzzy_image_hash call so
it's run in matcher
This commit is contained in:
Solal Jacob 2024-01-18 18:11:30 +01:00
parent 4cd9578df9
commit 1ea486f6b7
2 changed files with 5 additions and 3 deletions

View file

@ -186,6 +186,7 @@ static inline cl_error_t matcher_run(const struct cli_matcher *root,
}
switch (ftype) {
case CL_TYPE_PDF:
case CL_TYPE_GIF:
case CL_TYPE_TIFF:
case CL_TYPE_JPEG:

View file

@ -4900,6 +4900,10 @@ cl_error_t cli_magic_scan(cli_ctx *ctx, cli_file_t type)
ret = cli_scan_structured(ctx);
break;
case CL_TYPE_PDF:
if (SCAN_PARSE_PDF && (DCONF_DOC & DOC_CONF_PDF))
(void)calculate_fuzzy_image_hash(ctx, type);
default:
break;
}
@ -4995,9 +4999,6 @@ cl_error_t cli_magic_scan(cli_ctx *ctx, cli_file_t type)
if (SCAN_PARSE_PDF && (DCONF_DOC & DOC_CONF_PDF))
ret = cli_scanpdf(ctx, 0);
// we may still want to calculate the fuzzy hash for the rendering page, even if parsing fail as the pdf parser is different and may parse the file sucessfully
(void)calculate_fuzzy_image_hash(ctx, type);
break;
default: