Browse code

cli_scanhtml: Respect file size limit

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@780 77e5149b-7576-45b1-b177-96237e5ba77b

Tomasz Kojm authored on 2004/08/22 21:21:22
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Sun Aug 22 14:18:53 CEST 2004 (tk)
2
+----------------------------------
3
+  * libclamav: cli_scanhtml: Respect file size limit
4
+
1 5
 Sun Aug 22 11:35:30 BST 2004 (njh)
2 6
 ----------------------------------
3 7
   * libclamav:	Save email attachments to disc earlier (as the attachment is
... ...
@@ -654,6 +654,7 @@ static int cli_scanhtml(int desc, const char **virname, long int *scanned, const
654 654
 	int ret;
655 655
 
656 656
 
657
+#ifdef HAVE_MMAP
657 658
     cli_dbgmsg("in cli_scanhtml()\n");
658 659
 
659 660
     if(fstat(desc, &statbuf) != 0) {
... ...
@@ -661,7 +662,11 @@ static int cli_scanhtml(int desc, const char **virname, long int *scanned, const
661 661
         return CL_EIO;
662 662
     }
663 663
 
664
-#ifdef HAVE_MMAP
664
+    if(limits && limits->maxfilesize && (statbuf.st_size > limits->maxfilesize)) {
665
+	cli_dbgmsg("ScanHTML -> Size exceeded (%d, max: %ld)\n", statbuf.st_size, limits->maxfilesize);
666
+	return CL_CLEAN;
667
+    }
668
+
665 669
     membuff = mmap(NULL, statbuf.st_size, PROT_READ, MAP_PRIVATE, desc, 0);
666 670
 
667 671
     /* TODO: do file operations if mmap fails */