Browse code

avoid calling cli_scanscript() for HTML files

git-svn: trunk@3669

Tomasz Kojm authored on 2008/02/22 20:38:30
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Fri Feb 22 11:38:41 CET 2008 (tk)
2
+---------------------------------
3
+  * libclamav/scanners.c: avoid calling cli_scanscript() for HTML files
4
+
1 5
 Fri Feb 22 00:24:41 CET 2008 (tk)
2 6
 ---------------------------------
3 7
   * libclamav: use limits->maxfiles instead of MAX_EMBEDDED_OBJ for ZIP-SFX
... ...
@@ -1516,7 +1516,7 @@ static int cli_scanembpe(int desc, cli_ctx *ctx)
1516 1516
     return CL_CLEAN;
1517 1517
 }
1518 1518
 
1519
-static int cli_scanraw(int desc, cli_ctx *ctx, cli_file_t type, uint8_t typercg)
1519
+static int cli_scanraw(int desc, cli_ctx *ctx, cli_file_t type, uint8_t typercg, cli_file_t *dettype)
1520 1520
 {
1521 1521
 	int ret = CL_CLEAN, nret = CL_CLEAN;
1522 1522
 	struct cli_matched_type *ftoffset = NULL, *fpt;
... ...
@@ -1638,8 +1638,10 @@ static int cli_scanraw(int desc, cli_ctx *ctx, cli_file_t type, uint8_t typercg)
1638 1638
 
1639 1639
 	if(nret != CL_VIRUS) switch(ret) {
1640 1640
 	    case CL_TYPE_HTML:
1641
-		if(SCAN_HTML && type == CL_TYPE_TEXT_ASCII && (DCONF_DOC & DOC_CONF_HTML))
1641
+		if(SCAN_HTML && type == CL_TYPE_TEXT_ASCII && (DCONF_DOC & DOC_CONF_HTML)) {
1642
+		    *dettype = CL_TYPE_HTML;
1642 1643
 		    nret = cli_scanhtml(desc, ctx);
1644
+		}
1643 1645
 		break;
1644 1646
 
1645 1647
 	    case CL_TYPE_MAIL:
... ...
@@ -1669,7 +1671,7 @@ static int cli_scanraw(int desc, cli_ctx *ctx, cli_file_t type, uint8_t typercg)
1669 1669
 int cli_magic_scandesc(int desc, cli_ctx *ctx)
1670 1670
 {
1671 1671
 	int ret = CL_CLEAN;
1672
-	cli_file_t type;
1672
+	cli_file_t type, dettype = 0;
1673 1673
 	struct stat sb;
1674 1674
 	uint8_t typercg = 1;
1675 1675
 
... ...
@@ -1713,7 +1715,7 @@ int cli_magic_scandesc(int desc, cli_ctx *ctx)
1713 1713
     lseek(desc, 0, SEEK_SET);
1714 1714
 
1715 1715
     if(type != CL_TYPE_IGNORED && ctx->engine->sdb) {
1716
-	if((ret = cli_scanraw(desc, ctx, type, 0)) == CL_VIRUS)
1716
+	if((ret = cli_scanraw(desc, ctx, type, 0, &dettype)) == CL_VIRUS)
1717 1717
 	    return CL_VIRUS;
1718 1718
 	lseek(desc, 0, SEEK_SET);
1719 1719
     }
... ...
@@ -1785,8 +1787,7 @@ int cli_magic_scandesc(int desc, cli_ctx *ctx)
1785 1785
 	    break;
1786 1786
 
1787 1787
 	case CL_TYPE_SCRIPT:
1788
-	case CL_TYPE_TEXT_ASCII:
1789
-	    if(DCONF_DOC & DOC_CONF_SCRIPT)
1788
+	    if((DCONF_DOC & DOC_CONF_SCRIPT) && dettype != CL_TYPE_HTML)
1790 1789
 	        ret = cli_scanscript(desc, ctx);
1791 1790
 	    break;
1792 1791
 
... ...
@@ -1889,13 +1890,17 @@ int cli_magic_scandesc(int desc, cli_ctx *ctx)
1889 1889
 
1890 1890
     /* CL_TYPE_HTML: raw HTML files are not scanned, unless safety measure activated via DCONF */
1891 1891
     if(type != CL_TYPE_IGNORED && (type != CL_TYPE_HTML || !(DCONF_DOC & DOC_CONF_HTML_SKIPRAW)) && ret != CL_VIRUS && !ctx->engine->sdb) {
1892
-	if(cli_scanraw(desc, ctx, type, typercg) == CL_VIRUS)
1892
+	if(cli_scanraw(desc, ctx, type, typercg, &dettype) == CL_VIRUS)
1893 1893
 	    return CL_VIRUS;
1894 1894
     }
1895 1895
 
1896 1896
     ctx->recursion++;
1897 1897
     lseek(desc, 0, SEEK_SET);
1898 1898
     switch(type) {
1899
+	case CL_TYPE_TEXT_ASCII:
1900
+	    if((DCONF_DOC & DOC_CONF_SCRIPT) && dettype != CL_TYPE_HTML)
1901
+	        ret = cli_scanscript(desc, ctx);
1902
+	    break;
1899 1903
 	/* Due to performance reasons all executables were first scanned
1900 1904
 	 * in raw mode. Now we will try to unpack them
1901 1905
 	 */