mirror of
https://github.com/Cisco-Talos/clamav.git
synced 2025-10-19 10:23:17 +00:00
bb#10363 - allowed for multiple filetypes for a single target
This commit is contained in:
parent
310f3c9f17
commit
2c0fa85f2c
2 changed files with 33 additions and 25 deletions
|
@ -158,7 +158,7 @@ static inline int matcher_run(const struct cli_matcher *root,
|
|||
int cli_scanbuff(const unsigned char *buffer, uint32_t length, uint32_t offset, cli_ctx *ctx, cli_file_t ftype, struct cli_ac_data **acdata)
|
||||
{
|
||||
int ret = CL_CLEAN;
|
||||
unsigned int i, viruses_found = 0;
|
||||
unsigned int i = 0, j = 0, viruses_found = 0;
|
||||
struct cli_ac_data mdata;
|
||||
struct cli_matcher *groot, *troot = NULL;
|
||||
const char *virname = NULL;
|
||||
|
@ -172,12 +172,15 @@ int cli_scanbuff(const unsigned char *buffer, uint32_t length, uint32_t offset,
|
|||
groot = engine->root[0]; /* generic signatures */
|
||||
|
||||
if(ftype) {
|
||||
for(i = 1; i < CLI_MTARGETS; i++) {
|
||||
if(cli_mtargets[i].target == ftype) {
|
||||
troot = engine->root[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
for(i = 1; i < CLI_MTARGETS; i++) {
|
||||
for (j = 0; j < cli_mtargets[i].target_count; ++j) {
|
||||
if(cli_mtargets[i].target[j] == ftype) {
|
||||
troot = ctx->engine->root[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (troot) break;
|
||||
}
|
||||
}
|
||||
|
||||
if(troot) {
|
||||
|
@ -706,7 +709,7 @@ int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli
|
|||
{
|
||||
const unsigned char *buff;
|
||||
int ret = CL_CLEAN, type = CL_CLEAN, bytes, compute_hash[CLI_HASH_AVAIL_TYPES];
|
||||
unsigned int i = 0, bm_offmode = 0;
|
||||
unsigned int i = 0, j = 0, bm_offmode = 0;
|
||||
uint32_t maxpatlen, offset = 0;
|
||||
struct cli_ac_data gdata, tdata;
|
||||
struct cli_bm_off toff;
|
||||
|
@ -759,10 +762,13 @@ int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli
|
|||
|
||||
if(ftype) {
|
||||
for(i = 1; i < CLI_MTARGETS; i++) {
|
||||
if(cli_mtargets[i].target == ftype) {
|
||||
troot = ctx->engine->root[i];
|
||||
break;
|
||||
for (j = 0; j < cli_mtargets[i].target_count; ++j) {
|
||||
if(cli_mtargets[i].target[j] == ftype) {
|
||||
troot = ctx->engine->root[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (troot) break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -130,29 +130,31 @@ struct cli_cdb
|
|||
struct cli_cdb *next;
|
||||
};
|
||||
|
||||
#define CLI_MAX_TARGETS 2 /* maximum filetypes for a specific target */
|
||||
struct cli_mtarget {
|
||||
cli_file_t target;
|
||||
cli_file_t target[CLI_MAX_TARGETS];
|
||||
const char *name;
|
||||
uint8_t idx; /* idx of matcher */
|
||||
uint8_t ac_only;
|
||||
uint8_t enable_prefiltering;
|
||||
uint8_t target_count; /* must be synced with non-zero values in the target array */
|
||||
};
|
||||
|
||||
#define CLI_MTARGETS 13
|
||||
static const struct cli_mtarget cli_mtargets[CLI_MTARGETS] = {
|
||||
{ 0, "GENERIC", 0, 0, 1 },
|
||||
{ CL_TYPE_MSEXE, "PE", 1, 0, 1 },
|
||||
{ CL_TYPE_MSOLE2, "OLE2", 2, 1, 0 },
|
||||
{ CL_TYPE_HTML, "HTML", 3, 1, 0 },
|
||||
{ CL_TYPE_MAIL, "MAIL", 4, 1, 1 },
|
||||
{ CL_TYPE_GRAPHICS, "GRAPHICS", 5, 1, 0 },
|
||||
{ CL_TYPE_ELF, "ELF", 6, 1, 0 },
|
||||
{ CL_TYPE_TEXT_ASCII, "ASCII", 7, 1, 1 },
|
||||
{ CL_TYPE_ERROR, "NOT USED", 8, 1, 0 },
|
||||
{ CL_TYPE_MACHO, "MACH-O", 9, 1, 0 },
|
||||
{ CL_TYPE_PDF, "PDF", 10, 1, 0 },
|
||||
{ CL_TYPE_SWF, "FLASH", 11, 1, 0 },
|
||||
{ CL_TYPE_JAVA, "JAVA", 12, 1, 0 }
|
||||
{ {0, 0}, "GENERIC", 0, 0, 1, 1 },
|
||||
{ {CL_TYPE_MSEXE, 0}, "PE", 1, 0, 1, 1 },
|
||||
{ {CL_TYPE_MSOLE2, 0}, "OLE2", 2, 1, 0, 1 },
|
||||
{ {CL_TYPE_HTML, 0}, "HTML", 3, 1, 0, 1 },
|
||||
{ {CL_TYPE_MAIL, 0}, "MAIL", 4, 1, 1, 1 },
|
||||
{ {CL_TYPE_GRAPHICS, 0}, "GRAPHICS", 5, 1, 0, 1 },
|
||||
{ {CL_TYPE_ELF, 0}, "ELF", 6, 1, 0, 1 },
|
||||
{ {CL_TYPE_TEXT_ASCII, 0}, "ASCII", 7, 1, 1, 1 },
|
||||
{ {CL_TYPE_ERROR, 0}, "NOT USED", 8, 1, 0, 1 },
|
||||
{ {CL_TYPE_MACHO, CL_TYPE_MACHO_UNIBIN}, "MACH-O", 9, 1, 0, 2 },
|
||||
{ {CL_TYPE_PDF, 0}, "PDF", 10, 1, 0, 1 },
|
||||
{ {CL_TYPE_SWF, 0}, "FLASH", 11, 1, 0, 1 },
|
||||
{ {CL_TYPE_JAVA, 0}, "JAVA", 12, 1, 0, 1 }
|
||||
};
|
||||
|
||||
#define CLI_OFF_ANY 0xffffffff
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue