set dont_cache_flag on the fmap stack

0.96
aCaB 15 years ago
parent 047e50be76
commit 742b3a0e06
  1. 1
      libclamav/matcher.c
  2. 22
      libclamav/scanners.c

@ -407,6 +407,7 @@ int cli_scandesc(int desc, cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struc
if((*ctx->fmap = fmap(desc, 0, 0))) {
ret = cli_fmap_scandesc(ctx, ftype, ftonly, ftoffset, acmode, NULL);
map->dont_cache_flag = (*ctx->fmap)->dont_cache_flag;
funmap(*ctx->fmap);
}
*ctx->fmap = map;

@ -1869,6 +1869,16 @@ static int cli_scanraw(cli_ctx *ctx, cli_file_t type, uint8_t typercg, cli_file_
}
static void emax_reached(cli_ctx *ctx) {
fmap_t **ctx_fmap = ctx->fmap;
while(*ctx_fmap) {
fmap_t *map = *ctx_fmap;
map->dont_cache_flag = 1;
ctx_fmap--;
}
cli_dbgmsg("emax_reached: marked parents as non cacheable\n");
}
#define LINESTR(x) #x
#define LINESTR2(x) LINESTR(x)
#define __AT__ " at line "LINESTR2(__LINE__)
@ -1876,6 +1886,7 @@ static int cli_scanraw(cli_ctx *ctx, cli_file_t type, uint8_t typercg, cli_file_
cli_dbgmsg("cli_magic_scandesc: returning %d %s\n", retcode, __AT__); \
return retcode; \
} while(0)
int cli_magic_scandesc(int desc, cli_ctx *ctx)
{
int ret = CL_CLEAN;
@ -1890,7 +1901,8 @@ int cli_magic_scandesc(int desc, cli_ctx *ctx)
cli_dbgmsg("in cli_magic_scandesc (reclevel: %u/%u)\n", ctx->recursion, ctx->engine->maxreclevel);
if(ctx->engine->maxreclevel && ctx->recursion > ctx->engine->maxreclevel) {
cli_dbgmsg("cli_magic_scandesc: Archive recursion limit exceeded (%u, max: %u)\n", ctx->recursion, ctx->engine->maxreclevel);
ret_from_magicscan(CL_CLEAN); /* FIXMEDONTCACHE */
emax_reached(ctx);
ret_from_magicscan(CL_CLEAN);
}
if(fstat(desc, &sb) == -1) {
@ -1913,8 +1925,10 @@ int cli_magic_scandesc(int desc, cli_ctx *ctx)
ret_from_magicscan(CL_EMALFDB);
}
if(cli_updatelimits(ctx, sb.st_size)!=CL_CLEAN)
ret_from_magicscan(CL_CLEAN); /* FIXMEDONTCACHE */
if(cli_updatelimits(ctx, sb.st_size)!=CL_CLEAN) {
emax_reached(ctx);
ret_from_magicscan(CL_CLEAN);
}
ctx->fmap++;
if(!(*ctx->fmap = fmap(desc, 0, sb.st_size))) {
@ -1944,7 +1958,7 @@ int cli_magic_scandesc(int desc, cli_ctx *ctx)
if(ctx->recursion != ctx->engine->maxreclevel)
cache_add(hash, hashed_size, ctx); /* Only cache if limits are not reached */
else
{} /* FIXMEDONTCACHE */
emax_reached(ctx);
}
funmap(*ctx->fmap);

Loading…
Cancel
Save