Skip to content

Commit f10a037

Browse files
committed
Improve strictness of max-scantime
Some files that take longer to scan may exceed the scan time by a fair bit during the actual pattern matching part of the scan (vs. decompressing archives or running bytecode functions, or whatever). ClamAV does pattern matching and hashing of files in chunks. This change adds a time check before each chunk is matched.
1 parent c52b169 commit f10a037

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

libclamav/matcher.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,12 @@ cl_error_t cli_scan_fmap(cli_ctx *ctx, cli_file_t ftype, bool filetype_only, str
12541254
}
12551255

12561256
while (offset < ctx->fmap->len) {
1257+
if (cli_checktimelimit(ctx) != CL_SUCCESS) {
1258+
cli_dbgmsg("Exceeded scan time limit while scanning fmap (max: %u)\n", ctx->engine->maxscantime);
1259+
ret = CL_ETIMEOUT;
1260+
goto done;
1261+
}
1262+
12571263
bytes = MIN(ctx->fmap->len - offset, SCANBUFF);
12581264
if (!(buff = fmap_need_off_once(ctx->fmap, offset, bytes)))
12591265
break;

0 commit comments

Comments
 (0)