s/need/unneed/ in unzip, remove debug spam and comments in matcher.c

0.96
aCaB 16 years ago
parent 786766eb47
commit b183aa786b
  1. 25
      libclamav/matcher.c
  2. 16
      libclamav/unzip.c

@ -386,18 +386,7 @@ int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli
cli_md5_init(&md5ctx);
while(offset < map->len) {
/* TO TOMASZ:
by swapping comments on the following 2 lines and in the other 2 lines below you
can mimic the bahaviour of master in terms of which offsets we break the blocks at
Offsets in master are: 0, 130680, 261752, 392824, 523896, 654968, 786040, 917112
Offsets in the fmap are: 0, 130680, 261360, 392040, 522720, 653400, 784080, 914760
I think maxpatlen is a bit too short. In practice, due to the SCANBUFF/maxpatlen ratio
this is not a huge problem: during the regression it only affected 3 samples out of 3.5M
*/
/* UNCOMMENT ME */ //bytes = MIN(map->len - offset, SCANBUFF + maxpatlen * (offset != 0));
/* COMMENT ME */ bytes = MIN(map->len - offset, SCANBUFF);
cli_errmsg("off: %u\n", offset);
bytes = MIN(map->len - offset, SCANBUFF);
if(!(buff = fmap_need_off_once(map, offset, bytes)))
break;
if(ctx->scanned)
@ -444,18 +433,8 @@ int cli_fmap_scandesc(cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli
cli_md5_update(&md5ctx, buff + maxpatlen * (offset!=0), bytes - maxpatlen * (offset!=0));
}
/* TO TOMASZ:
That's the second block you need to swap in order to to match the swap above
*/
/* UNCOMMENT ME */ //if(bytes < SCANBUFF + maxpatlen * (offset != 0)) break;
/* COMMENT ME */ if(bytes < SCANBUFF) break;
if(bytes < SCANBUFF) break;
offset += bytes - maxpatlen;
/* TO TOMASZ:
as an additional check you can leave the above code untouched and replace the previous line with:
offset += bytes - (maxpatlen + 63);
Note that I'm not sure maxpatlen is only 63 bytes short, but with *this* specific sample case it's enough.
*/
}
if(troot) {

@ -325,7 +325,7 @@ static unsigned int lhdr(fmap_t *map, uint32_t loff,uint32_t zsize, unsigned int
if(zsize<=LH_flen) {
cli_dbgmsg("cli_unzip: lh - fname out of file\n");
fmap_need_off(map, loff, SIZEOF_LH);
fmap_unneed_off(map, loff, SIZEOF_LH);
return 0;
}
if(meta || cli_debug_flag) {
@ -362,14 +362,14 @@ static unsigned int lhdr(fmap_t *map, uint32_t loff,uint32_t zsize, unsigned int
} else
*ret = CL_CLEAN;
fmap_need_off(map, loff, SIZEOF_LH);
fmap_unneed_off(map, loff, SIZEOF_LH);
return 0;
}
if(LH_flags & F_MSKED) {
cli_dbgmsg("cli_unzip: lh - header has got unusable masked data\n");
/* FIXME: need to find/craft a sample */
fmap_need_off(map, loff, SIZEOF_LH);
fmap_unneed_off(map, loff, SIZEOF_LH);
return 0;
}
@ -377,14 +377,14 @@ static unsigned int lhdr(fmap_t *map, uint32_t loff,uint32_t zsize, unsigned int
cli_dbgmsg("cli_unzip: Encrypted files found in archive.\n");
*ctx->virname = "Encrypted.Zip";
*ret = CL_VIRUS;
fmap_need_off(map, loff, SIZEOF_LH);
fmap_unneed_off(map, loff, SIZEOF_LH);
return 0;
}
if(LH_flags & F_USEDD) {
cli_dbgmsg("cli_unzip: lh - has data desc\n");
if(!ch) {
fmap_need_off(map, loff, SIZEOF_LH);
fmap_unneed_off(map, loff, SIZEOF_LH);
return 0;
}
else { usize = CH_usize; csize = CH_csize; }
@ -392,7 +392,7 @@ static unsigned int lhdr(fmap_t *map, uint32_t loff,uint32_t zsize, unsigned int
if(zsize<=LH_elen) {
cli_dbgmsg("cli_unzip: lh - extra out of file\n");
fmap_need_off(map, loff, SIZEOF_LH);
fmap_unneed_off(map, loff, SIZEOF_LH);
return 0;
}
zip+=LH_elen;
@ -403,7 +403,7 @@ static unsigned int lhdr(fmap_t *map, uint32_t loff,uint32_t zsize, unsigned int
} else {
if(zsize<csize) {
cli_dbgmsg("cli_unzip: lh - stream out of file\n");
fmap_need_off(map, loff, SIZEOF_LH);
fmap_unneed_off(map, loff, SIZEOF_LH);
return 0;
}
if(LH_flags & F_ENCR) {
@ -416,7 +416,7 @@ static unsigned int lhdr(fmap_t *map, uint32_t loff,uint32_t zsize, unsigned int
zsize-=csize;
}
fmap_need_off(map, loff, SIZEOF_LH); /* unneed now. block is guaranteed to exists till the next need */
fmap_unneed_off(map, loff, SIZEOF_LH); /* unneed now. block is guaranteed to exists till the next need */
if(LH_flags & F_USEDD) {
if(zsize<12) {
cli_dbgmsg("cli_unzip: lh - data desc out of file\n");

Loading…
Cancel
Save