[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. 99ae9353f6834da0cb73f59f4b32d1f0ae1263fa

Stephen Gran steve at lobefin.net
Thu Sep 4 12:36:51 UTC 2008


The following commit has been merged in the debian/unstable branch:
commit a14953873fc4ce30c463a5e9c610a6d963cf6d3c
Author: Stephen Gran <steve at lobefin.net>
Date:   Thu Sep 4 13:25:28 2008 +0100

    Revert "scan broken ole2 files"
    
    This reverts commit 31a6a2eb48376ee1c7ab4d33f90f217035d56713.

diff --git a/ChangeLog b/ChangeLog
index d3b96d2..1cf29af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,3 @@
-Tue May 27 21:22:42 CEST 2008 (acab)
-------------------------------------
-  * libclamav/ole2_extract.c: partial scan of broken ole files
-
 Mon May 26 22:06:55 CEST 2008
 -----------------------------
   * 0.93.1rc1: improve handling of PDF, CAB, RTF, OLE2 and HTML files
diff --git a/libclamav/ole2_extract.c b/libclamav/ole2_extract.c
index 07e8230..6cec13f 100644
--- a/libclamav/ole2_extract.c
+++ b/libclamav/ole2_extract.c
@@ -191,7 +191,7 @@ static char *get_property_name(char *name, int size) {
   char *newname, *cname;
   char *oname = name;
 
-  if (csize<=0) return NULL;
+	if (csize<=0) return NULL;
 
   newname = cname = (char *)cli_malloc(size);
   if (!newname) return NULL;
@@ -800,22 +800,42 @@ static int handler_otf(int fd, ole2_header_t *hdr, property_t *prop, const char
   while((current_block >= 0) && (len > 0)) {
     if (current_block > (int32_t) hdr->max_block_no) {
       cli_dbgmsg("OLE2: Max block number for file size exceeded: %d\n", current_block);
-      break;
+      close(ofd);
+      free(buff);
+      cli_bitset_free(blk_bitset);
+      unlink(tempfile);
+      free(tempfile);
+      return CL_SUCCESS;
     }
     /* Check we aren't in a loop */
     if (cli_bitset_test(blk_bitset, (unsigned long) current_block)) {
       /* Loop in block list */
       cli_dbgmsg("OLE2: Block list loop detected\n");
-      break;
+      close(ofd);
+      free(buff);
+      cli_bitset_free(blk_bitset);
+      unlink(tempfile);
+      free(tempfile);
+      return CL_BREAK;
     }
     if (!cli_bitset_set(blk_bitset, (unsigned long) current_block)) {
-      break;
+      close(ofd);
+      free(buff);
+      cli_bitset_free(blk_bitset);
+      unlink(tempfile);
+      free(tempfile);
+      return CL_BREAK;
     }			
     if (prop->size < (int64_t)hdr->sbat_cutoff) {
       /* Small block file */
       if (!ole2_get_sbat_data_block(fd, hdr, buff, current_block)) {
 	cli_dbgmsg("ole2_get_sbat_data_block failed\n");
-	break;
+	close(ofd);
+	free(buff);
+	cli_bitset_free(blk_bitset);
+	unlink(tempfile);
+	free(tempfile);
+	return CL_SUCCESS;
       }
       /* buff now contains the block with 8 small blocks in it */
       offset = 64 * (current_block % 8);
@@ -833,7 +853,12 @@ static int handler_otf(int fd, ole2_header_t *hdr, property_t *prop, const char
     } else {
       /* Big block file */
       if (!ole2_read_block(fd, hdr, buff, current_block)) {
-	break;
+	close(ofd);
+	free(buff);
+	cli_bitset_free(blk_bitset);
+	unlink(tempfile);
+	free(tempfile);
+	return CL_SUCCESS;
       }
       if (cli_writen(ofd, buff, MIN(len,(1 << hdr->log2_big_block_size))) !=
 	  MIN(len,(1 << hdr->log2_big_block_size))) {
@@ -842,7 +867,7 @@ static int handler_otf(int fd, ole2_header_t *hdr, property_t *prop, const char
 	cli_bitset_free(blk_bitset);
 	unlink(tempfile);
 	free(tempfile);
-	return CL_EIO;
+	return CL_BREAK;
       }
 
       current_block = ole2_get_next_block_number(fd, hdr, current_block);
@@ -995,9 +1020,8 @@ int cli_ole2_extract(int fd, const char *dirname, cli_ctx *ctx, struct uniq **vb
 	hdr.sbat_root_start = -1;
 
 	hdr.bitset = cli_bitset_init();
-	if (!hdr.bitset) {
-		ret=CL_EOLE2;
-		goto abort;
+	if (!hdr.bitset) { /* FIXME: mmap leaks here */
+		return CL_EOLE2;
 	}
 
 	if (memcmp(hdr.magic, magic_id, 8) != 0) {
@@ -1025,6 +1049,13 @@ int cli_ole2_extract(int fd, const char *dirname, cli_ctx *ctx, struct uniq **vb
 	print_ole2_header(&hdr);
 	cli_dbgmsg("Max block number: %lu\n", (unsigned long int) hdr.max_block_no);
 
+	/* NOTE: Select only ONE of the following two methods */
+	
+	/* ole2_read_property_tree(fd, &hdr, dirname, handler_writefile); */
+	
+	/* OR */
+	
+
 	/* PASS 1 : Count files and check for VBA */
 	//	__asm__ __volatile__("int3");
 	hdr.has_vba = 0;
@@ -1048,7 +1079,7 @@ int cli_ole2_extract(int fd, const char *dirname, cli_ctx *ctx, struct uniq **vb
 	  ret = CL_CLEAN;
 	  *vba = hdr.U;
 	} else {
-	  cli_dbgmsg("OLE2: no VBA projects found\n");
+	  cli_dbgmsg("OLE2: no VBA projects found %d\n", ret);
 	  /* PASS 2/B : OTF scan */
 	  file_count = 0;
 	  ret = ole2_walk_property_tree(fd, &hdr, NULL, 0, handler_otf, 0, &file_count, ctx, &scansize2);

-- 
Debian repository for ClamAV



More information about the Pkg-clamav-commits mailing list