Browse code

don't call phishing_init() if not needed (bb#147)

git-svn: trunk@2518

Tomasz Kojm authored on 2006/11/24 10:08:25
Showing 7 changed files
... ...
@@ -1,3 +1,8 @@
1
+Fri Nov 24 02:01:48 CET 2006 (tk)
2
+---------------------------------
3
+  * libclamav: don't call phishing_init() if not needed (bb#147),
4
+	       patch from Edvin, mbox related part of the patch passed to NJH
5
+
1 6
 Fri Nov 24 01:15:28 CET 2006 (tk)
2 7
 ---------------------------------
3 8
   * libclamav/matcher.c: minor code cleanup (bb#148), thanks to Christophe
... ...
@@ -301,7 +301,7 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned in
301 301
 
302 302
 #ifdef CL_EXPERIMENTAL
303 303
     if(!cfgopt(copt,"PhishingScanURLs")->enabled)
304
-	options |= CL_SCAN_NOPHISHING;
304
+	dboptions |= CL_DB_NOPHISHING_URLS;
305 305
     if(cfgopt(copt,"PhishingStrictURLCheck")->enabled)
306 306
 	options |= CL_PHISH_NO_DOMAINLIST;
307 307
 #endif
... ...
@@ -252,7 +252,7 @@ void help(void)
252 252
 #endif
253 253
     mprintf("\n");
254 254
     mprintf("    --no-mail                            Disable mail file support\n");
255
-    mprintf("    --no-phishing                        Disable phishing detection\n");
255
+    mprintf("    --no-phishing                        Disable signature-based phishing detection\n");
256 256
 #ifdef CL_EXPERIMENTAL
257 257
     mprintf("    --no-phishing-scan-urls              Disable url-based phishing detection\n");
258 258
     mprintf("    --phishing-strict-url-check          Enable phishing detection for all domains (might lead to false positives!)\n");
... ...
@@ -94,7 +94,7 @@ int scanmanager(const struct optstruct *opt)
94 94
 
95 95
 #ifdef CL_EXPERIMENTAL
96 96
     if(opt_check(opt,"no-phishing-scan-urls"))
97
-	options |= CL_SCAN_NOPHISHING;
97
+	dboptions |= CL_DB_NOPHISHING_URLS;
98 98
     if(opt_check(opt,"phishing-strict-url-check"))
99 99
 	options |= CL_PHISH_NO_DOMAINLIST;
100 100
 #endif
... ...
@@ -2,7 +2,7 @@
2 2
 from popen2 import popen4;
3 3
 import sys;
4 4
 import os;
5
-out = popen4("clamscan/clamscan -d database --phish-scan-alldomains --debug "+sys.argv[1])[0]
5
+out = popen4("clamscan/clamscan -d database --phishing-strict-url-check --debug "+sys.argv[1])[0]
6 6
 lines = out.read().split("\n")
7 7
 PHISH_FOUND="Phishing found"
8 8
 URL_CHECK="Checking url"
... ...
@@ -71,6 +71,7 @@ extern "C"
71 71
 #define CL_DB_NCORE	    0x1
72 72
 #define CL_DB_NOPHISHING    0x2
73 73
 #define CL_DB_ACONLY	    0x4 /* WARNING: only for developers */
74
+#define CL_DB_NOPHISHING_URLS 0x8
74 75
 
75 76
 /* recommended db settings */
76 77
 #define CL_DB_STDOPT	    0x0
... ...
@@ -87,7 +88,6 @@ extern "C"
87 87
 #define CL_SCAN_MAILURL		0x80
88 88
 #define CL_SCAN_BLOCKMAX	0x100
89 89
 #define CL_SCAN_ALGO		0x200
90
-#define CL_SCAN_NOPHISHING      0x400
91 90
 #define CL_PHISH_NO_DOMAINLIST  0x800
92 91
 #define CL_SCAN_ELF		0x1000
93 92
 
... ...
@@ -478,7 +478,7 @@ int cli_parse_add(struct cli_matcher *root, const char *virname, const char *hex
478 478
 static int cli_initengine(struct cl_engine **engine, unsigned int options)
479 479
 {
480 480
 #ifdef CL_EXPERIMENTAL
481
-	int rc;
481
+	int ret;
482 482
 #endif
483 483
 
484 484
 
... ...
@@ -502,8 +502,9 @@ static int cli_initengine(struct cl_engine **engine, unsigned int options)
502 502
     }
503 503
 
504 504
 #ifdef CL_EXPERIMENTAL
505
-    if((rc = phishing_init(*engine)))
506
-	return rc;
505
+    if(!(options & CL_DB_NOPHISHING_URLS))
506
+	if((ret = phishing_init(*engine)))
507
+	    return ret;
507 508
 #endif
508 509
 
509 510
     return CL_SUCCESS;
... ...
@@ -1198,12 +1199,12 @@ static int cli_load(const char *filename, struct cl_engine **engine, unsigned in
1198 1198
 	    skipped = 1;
1199 1199
 #ifdef CL_EXPERIMENTAL
1200 1200
     } else if(cli_strbcasestr(filename, ".wdb")) {
1201
-	if(!(options & CL_SCAN_NOPHISHING))
1201
+	if(!(options & CL_DB_NOPHISHING_URLS))
1202 1202
 	    ret = cli_loadwdb(fd, engine, options);
1203 1203
 	else
1204 1204
 	    skipped = 1;
1205 1205
     } else if(cli_strbcasestr(filename, ".pdb")) {
1206
-	if(!(options & CL_SCAN_NOPHISHING))
1206
+	if(!(options & CL_DB_NOPHISHING_URLS))
1207 1207
 	    ret = cli_loadpdb(fd, engine, options);
1208 1208
 	else
1209 1209
 	    skipped = 1;