Browse code

c4w: limit cloud queries to certain file types

aCaB authored on 2011/03/05 02:45:41
Showing 1 changed files
... ...
@@ -73,7 +73,7 @@ BOOL minimal_definitions = FALSE;
73 73
 #define lock_instances()(WaitForSingleObject(instance_mutex, INFINITE) == WAIT_FAILED)
74 74
 #define unlock_instances() do {ReleaseMutex(instance_mutex);} while(0)
75 75
 
76
-cl_error_t prescan_cb(int fd, void *context);
76
+cl_error_t prescan_cb(int fd, const char *detected_file_type, void *context);
77 77
 cl_error_t postscan_cb(int fd, int result, const char *virname, void *context);
78 78
 
79 79
 
... ...
@@ -987,7 +987,7 @@ int CLAMAPI Scan_DeleteScanInfo(CClamAVScanner *pScanner, PCLAM_SCAN_INFO_LIST p
987 987
     WIN();
988 988
 }
989 989
 
990
-cl_error_t prescan_cb(int fd, void *context) {
990
+cl_error_t prescan_cb(int fd, const char *type, void *context) {
991 991
     struct scan_ctx *sctx = (struct scan_ctx *)context;
992 992
     char tmpf[4096];
993 993
     instance *inst;
... ...
@@ -1001,7 +1001,16 @@ cl_error_t prescan_cb(int fd, void *context) {
1001 1001
 	return CL_CLEAN;
1002 1002
     }
1003 1003
     inst = sctx->inst;
1004
-    logg("*in prescan_cb with clamav context %p, instance %p, fd %d)\n", context, inst, fd);
1004
+    logg("*in prescan_cb with clamav context %p, instance %p, fd %d, type %s)\n", context, inst, fd, type);
1005
+    if(strncmp(type, "CL_TYPE_", 8) ||
1006
+       (strcmp(&type[8], "BINARY_DATA") &&
1007
+	strcmp(&type[8], "ANY") &&
1008
+	strcmp(&type[8], "MSEXE") &&
1009
+	strcmp(&type[8], "MSCAB") &&
1010
+	strcmp(&type[8], "OLE2")
1011
+	)
1012
+       ) logg("*prescan_cb: skipping scan of type %s\n", type);
1013
+
1005 1014
     si.cbSize = sizeof(si);
1006 1015
     si.flags = 0;
1007 1016
     si.scanPhase = (fd == sctx->entryfd) ? SCAN_PHASE_INITIAL : SCAN_PHASE_PRESCAN;