From 2b304af94281634bffcf34007c805c558e323620 Mon Sep 17 00:00:00 2001 From: Tomasz Kojm Date: Mon, 10 Dec 2007 15:33:46 +0000 Subject: [PATCH] eliminate some warning msgs git-svn: trunk@3386 --- ChangeLog | 4 ++++ libclamav/autoit.c | 24 ++++++++++++++++++------ libclamav/cab.c | 4 ++-- libclamav/sis.c | 4 ++-- libclamav/unzip.c | 2 +- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index bdd784a7a..dfc2ffc9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Dec 10 15:50:22 CET 2007 (tk) +--------------------------------- + * libclamav: eliminate some warning msgs + Sun Dec 9 11:43:03 EET 2007 (edwin) ------------------------------------ * shared/misc.c: pass mode to open with O_CREAT. diff --git a/libclamav/autoit.c b/libclamav/autoit.c index d45ae8157..50f7388c8 100644 --- a/libclamav/autoit.c +++ b/libclamav/autoit.c @@ -239,12 +239,17 @@ static int ea05(int desc, cli_ctx *ctx, char *tmpd) { cli_dbgmsg("autoit: bad file size - giving up\n"); return CL_CLEAN; } + + lseek(desc, 16, SEEK_CUR); + + if(!UNP.csize) { + cli_dbgmsg("autoit: skipping empty file\n"); + continue; + } cli_dbgmsg("autoit: compressed size: %x\n", UNP.csize); cli_dbgmsg("autoit: advertised uncompressed size %x\n", cli_readint32((char *)buf+5) ^ 0x45aa); cli_dbgmsg("autoit: ref chksum: %x\n", cli_readint32((char *)buf+9) ^ 0xc3d2); - lseek(desc, 16, SEEK_CUR); - if(ctx->limits && ctx->limits->maxfilesize && UNP.csize > ctx->limits->maxfilesize) { cli_dbgmsg("autoit: skipping file due to size limit (%u, max: %lu)\n", UNP.csize, ctx->limits->maxfilesize); lseek(desc, UNP.csize, SEEK_CUR); @@ -268,7 +273,8 @@ static int ea05(int desc, cli_ctx *ctx, char *tmpd) { continue; } - UNP.usize = be32_to_host(*(uint32_t *)(buf+4)); + if(!(UNP.usize = be32_to_host(*(uint32_t *)(buf+4)))) + UNP.usize = UNP.csize; /* only a specifically crafted or badly corrupted sample should land here */ if(ctx->limits && ctx->limits->maxfilesize && UNP.usize > ctx->limits->maxfilesize) { cli_dbgmsg("autoit: skipping file due to size limit (%u, max: %lu)\n", UNP.csize, ctx->limits->maxfilesize); free(buf); @@ -538,12 +544,17 @@ static int ea06(int desc, cli_ctx *ctx, char *tmpd) { cli_dbgmsg("autoit: bad file size - giving up\n"); return CL_CLEAN; } + + lseek(desc, 16, SEEK_CUR); + + if(!UNP.csize) { + cli_dbgmsg("autoit: skipping empty file\n"); + continue; + } cli_dbgmsg("autoit: compressed size: %x\n", UNP.csize); cli_dbgmsg("autoit: advertised uncompressed size %x\n", cli_readint32((char *)buf+5) ^ 0x87bc); cli_dbgmsg("autoit: ref chksum: %x\n", cli_readint32((char *)buf+9) ^ 0xa685); - lseek(desc, 16, SEEK_CUR); - if(ctx->limits && ctx->limits->maxfilesize && UNP.csize > ctx->limits->maxfilesize) { cli_dbgmsg("autoit: skipping file due to size limit (%u, max: %lu)\n", UNP.csize, ctx->limits->maxfilesize); lseek(desc, UNP.csize, SEEK_CUR); @@ -568,7 +579,8 @@ static int ea06(int desc, cli_ctx *ctx, char *tmpd) { continue; } - UNP.usize = be32_to_host(*(uint32_t *)(buf+4)); + if(!(UNP.usize = be32_to_host(*(uint32_t *)(buf+4)))) + UNP.usize = UNP.csize; /* only a specifically crafted or badly corrupted sample should land here */ if(ctx->limits && ctx->limits->maxfilesize && UNP.usize > ctx->limits->maxfilesize) { free(buf); continue; diff --git a/libclamav/cab.c b/libclamav/cab.c index 8429cc9fb..b257b4ac0 100644 --- a/libclamav/cab.c +++ b/libclamav/cab.c @@ -421,7 +421,7 @@ int cab_open(int fd, off_t offset, struct cab_archive *cab) if(fidx < 0xfffd) { if(fidx > cab->nfolders) { if(bscore < 3) - cli_warnmsg("cab_open: File %s is not associated with any folder\n", file->name); + cli_dbgmsg("cab_open: File %s is not associated with any folder\n", file->name); bscore++; free(file->name); free(file); @@ -465,7 +465,7 @@ static int cab_read_block(int fd, struct cab_state *state, uint16_t resdata) if(cli_readn(fd, &block_hdr, sizeof(block_hdr)) != sizeof(block_hdr)) { - cli_errmsg("cab_read_block: Can't read block header\n"); + cli_dbgmsg("cab_read_block: Can't read block header\n"); return CL_EIO; } diff --git a/libclamav/sis.c b/libclamav/sis.c index ea856ee37..8d0b4baae 100644 --- a/libclamav/sis.c +++ b/libclamav/sis.c @@ -77,7 +77,7 @@ static char *sis_utf16_decode(const char *str, uint32_t length) if(!length || length % 2) { - cli_warnmsg("SIS: sis_utf16_decode: Broken filename (length == %d)\n", length); + cli_dbgmsg("SIS: sis_utf16_decode: Broken filename (length == %d)\n", length); return NULL; } @@ -294,7 +294,7 @@ static int sis_extract_simple(int fd, char *mfile, uint32_t length, uint32_t off } if(uncompress((Bytef *) buff, &osize , (Bytef *) mfile + fileoff, csize) != Z_OK) { - cli_errmsg("SIS: sis_extract_simple: File decompression failed\n"); + cli_dbgmsg("SIS: sis_extract_simple: File decompression failed\n"); free(buff); free(subdir); free(fname); diff --git a/libclamav/unzip.c b/libclamav/unzip.c index 0ee892f27..af8369154 100644 --- a/libclamav/unzip.c +++ b/libclamav/unzip.c @@ -246,7 +246,7 @@ static int __zip_parse_root_directory(int fd, struct zip_disk_trailer *trailer, bfcnt = 0; if(!hdr->d_compr && hdr->d_csize != hdr->d_usize) { - cli_warnmsg("Unzip: __zip_parse_root_directory: File claims to be stored but csize != usize\n"); + cli_dbgmsg("Unzip: __zip_parse_root_directory: File claims to be stored but csize != usize\n"); cli_dbgmsg("Unzip: __zip_parse_root_directory: Also checking for method 'deflated'\n"); hdr->d_bf[bfcnt] = ZIP_METHOD_DEFLATED; bfcnt++;