... | ... |
@@ -136,6 +136,10 @@ typedef struct _CLAM_SCAN_INFO { |
136 | 136 |
/* Presence: ALWAYS */ |
137 | 137 |
const wchar_t *pInnerObjectPath; |
138 | 138 |
|
139 |
+ /** File type **/ |
|
140 |
+ /* Presence; SCAN_PHASE_POSTSCAN */ |
|
141 |
+ _int64 filetype[2]; |
|
142 |
+ |
|
139 | 143 |
} CLAM_SCAN_INFO, *PCLAM_SCAN_INFO; |
140 | 144 |
/* NOTE: all the objects within the above structure are guaranteed to be available and |
141 | 145 |
* valid until the callback returns (SCAN_PHASE_PRESCAN and SCAN_PHASE_POSTSCAN) or |
... | ... |
@@ -29,55 +29,54 @@ |
29 | 29 |
#include "interface.h" |
30 | 30 |
|
31 | 31 |
const char *types[] = { |
32 |
-"HTML", |
|
33 |
-"HTML_UTF16", |
|
34 |
-"MSEXE", |
|
35 |
-"GRAPHICS", |
|
36 |
-"TEXT_ASCII", |
|
37 |
-"TEXT_UTF8", |
|
38 |
-"TEXT_UTF16LE", |
|
39 |
-"TEXT_UTF16BE", |
|
40 |
-"PDF", |
|
41 |
-"SCRIPT", |
|
42 |
-"RTF", |
|
43 |
-"RIFF", |
|
44 |
-"MSCHM", |
|
45 |
-"MSCAB", |
|
46 |
-"MSOLE2", |
|
47 |
-"MSSZDD", |
|
48 |
-"ZIP", |
|
49 |
-"RAR", |
|
50 |
-"7Z", |
|
51 |
-"BZ", |
|
52 |
-"GZ", |
|
53 |
-"ARJ", |
|
54 |
-"ZIPSFX", |
|
55 |
-"RARSFX", |
|
56 |
-"CABSFX", |
|
57 |
-"ARJSFX", |
|
58 |
-"NULSFT", |
|
59 |
-"AUTOIT", |
|
60 |
-"ISHIELD_MSI", |
|
61 |
-"SFX", |
|
62 |
-"BINHEX", |
|
63 |
-"MAIL", |
|
64 |
-"TNEF", |
|
65 |
-"BINARY_DATA", |
|
66 |
-"CRYPTFF", |
|
67 |
-"UUENCODED", |
|
68 |
-"SCRENC", |
|
69 |
-"POSIX_TAR", |
|
70 |
-"OLD_TAR", |
|
71 |
-"ELF", |
|
72 |
-"MACHO", |
|
73 |
-"MACHO_UNIBIN", |
|
74 |
-"SIS", |
|
75 |
-"SWF", |
|
76 |
-"CPIO_OLD", |
|
77 |
-"CPIO_ODC", |
|
78 |
-"CPIO_NEWC", |
|
79 |
-"CPIO_CRC", |
|
80 |
-NULL |
|
32 |
+ "HTML", /* 0 */ |
|
33 |
+ "HTML_UTF16", /* 1 */ |
|
34 |
+ "MSEXE", /* 2 */ |
|
35 |
+ "GRAPHICS", /* 3 */ |
|
36 |
+ "TEXT_ASCII", /* 4 */ |
|
37 |
+ "TEXT_UTF8", /* 5 */ |
|
38 |
+ "TEXT_UTF16LE", /* 6 */ |
|
39 |
+ "TEXT_UTF16BE", /* 7 */ |
|
40 |
+ "PDF", /* 8 */ |
|
41 |
+ "SCRIPT", /* 9 */ |
|
42 |
+ "RTF", /* 10 */ |
|
43 |
+ "RIFF", /* 11 */ |
|
44 |
+ "MSCHM", /* 12 */ |
|
45 |
+ "MSCAB", /* 13 */ |
|
46 |
+ "MSOLE2", /* 14 */ |
|
47 |
+ "MSSZDD", /* 15 */ |
|
48 |
+ "ZIP", /* 16 */ |
|
49 |
+ "RAR", /* 17 */ |
|
50 |
+ "7Z", /* 18 */ |
|
51 |
+ "BZ", /* 19 */ |
|
52 |
+ "GZ", /* 20 */ |
|
53 |
+ "ARJ", /* 21 */ |
|
54 |
+ "ZIPSFX", /* 22 */ |
|
55 |
+ "RARSFX", /* 23 */ |
|
56 |
+ "CABSFX", /* 24 */ |
|
57 |
+ "ARJSFX", /* 25 */ |
|
58 |
+ "NULSFT", /* 26 */ |
|
59 |
+ "AUTOIT", /* 27 */ |
|
60 |
+ "ISHIELD_MSI", /* 28 */ |
|
61 |
+ "SFX", /* 29 */ |
|
62 |
+ "BINHEX", /* 30 */ |
|
63 |
+ "MAIL", /* 31 */ |
|
64 |
+ "TNEF", /* 32 */ |
|
65 |
+ "BINARY_DATA", /* 33 */ |
|
66 |
+ "CRYPTFF", /* 34 */ |
|
67 |
+ "UUENCODED", /* 35 */ |
|
68 |
+ "SCRENC", /* 36 */ |
|
69 |
+ "POSIX_TAR", /* 37 */ |
|
70 |
+ "OLD_TAR", /* 38 */ |
|
71 |
+ "ELF", /* 39 */ |
|
72 |
+ "MACHO", /* 40 */ |
|
73 |
+ "MACHO_UNIBIN", /* 41 */ |
|
74 |
+ "SIS", /* 42 */ |
|
75 |
+ "SWF", /* 43 */ |
|
76 |
+ "CPIO_ODC", /* 44 */ |
|
77 |
+ "CPIO_NEWC", /* 45 */ |
|
78 |
+ "CPIO_CRC", /* 46 */ |
|
79 |
+ NULL |
|
81 | 80 |
}; |
82 | 81 |
|
83 | 82 |
int WINAPI SHCreateDirectoryExA(HWND, LPCTSTR, SECURITY_ATTRIBUTES *); /* cannot include Shlobj.h due to DATADIR collision */ |
... | ... |
@@ -1054,28 +1053,33 @@ int CLAMAPI Scan_DeleteScanInfo(CClamAVScanner *pScanner, PCLAM_SCAN_INFO_LIST p |
1054 | 1054 |
WIN(); |
1055 | 1055 |
} |
1056 | 1056 |
|
1057 |
+ |
|
1058 |
+static void ftype_bits(const char *type, _int64 *filetype) { |
|
1059 |
+ int i; |
|
1060 |
+ if(strncmp(type, "CL_TYPE_", 8)) { |
|
1061 |
+ for(i=0; types[i]; i++) { |
|
1062 |
+ if(!strcmp(&type[8], types[i])) |
|
1063 |
+ break; |
|
1064 |
+ } |
|
1065 |
+ if(!types[i]) i = -1; |
|
1066 |
+ } else |
|
1067 |
+ i = -1; |
|
1068 |
+ if(i<0) { |
|
1069 |
+ filetype[0] = 0; |
|
1070 |
+ filetype[1] = 0; |
|
1071 |
+ } else if(i<64) { |
|
1072 |
+ filetype[0] = 1LL << i; |
|
1073 |
+ filetype[1] = 0; |
|
1074 |
+ } else { |
|
1075 |
+ filetype[0] = 0; |
|
1076 |
+ filetype[1] = 1LL << (i-64); |
|
1077 |
+ } |
|
1078 |
+} |
|
1079 |
+ |
|
1057 | 1080 |
cl_error_t filetype_cb(int fd, const char *type, void *context) { |
1058 | 1081 |
struct scan_ctx *sctx = (struct scan_ctx *)context; |
1059 | 1082 |
if(sctx && sctx->inst && sctx->inst->filetype) { |
1060 |
- int i=0; |
|
1061 |
- if(strncmp(type, "CL_TYPE_", 8)) { |
|
1062 |
- for(i=0; types[i]; i++) { |
|
1063 |
- if(!strcmp(&type[8], types[i])) |
|
1064 |
- break; |
|
1065 |
- } |
|
1066 |
- if(!types[i]) i = -1; |
|
1067 |
- } else |
|
1068 |
- i = -1; |
|
1069 |
- if(i<0) { |
|
1070 |
- sctx->inst->filetype[0] = -1; |
|
1071 |
- sctx->inst->filetype[1] = -1; |
|
1072 |
- } else if(i<64) { |
|
1073 |
- sctx->inst->filetype[0] = 1LL << i; |
|
1074 |
- sctx->inst->filetype[1] = 0; |
|
1075 |
- } else { |
|
1076 |
- sctx->inst->filetype[0] = 0; |
|
1077 |
- sctx->inst->filetype[1] = 1LL << (i-64); |
|
1078 |
- } |
|
1083 |
+ ftype_bits(type, sctx->inst->filetype); |
|
1079 | 1084 |
return CL_BREAK; |
1080 | 1085 |
} |
1081 | 1086 |
return CL_CLEAN; |
... | ... |
@@ -1099,15 +1103,7 @@ cl_error_t prescan_cb(int fd, const char *type, void *context) { |
1099 | 1099 |
return CL_CLEAN; /* Just in case, this shouldn't happen */ |
1100 | 1100 |
|
1101 | 1101 |
logg("*in prescan_cb with clamav context %p, instance %p, fd %d, type %s)\n", context, inst, fd, type); |
1102 |
- if(strncmp(type, "CL_TYPE_", 8) || |
|
1103 |
- (strcmp(&type[8], "BINARY_DATA") && |
|
1104 |
- strcmp(&type[8], "ANY") && |
|
1105 |
- strcmp(&type[8], "MSEXE") && |
|
1106 |
- strcmp(&type[8], "MSCAB") && |
|
1107 |
- strcmp(&type[8], "OLE2") |
|
1108 |
- ) |
|
1109 |
- ) logg("*prescan_cb: skipping scan of type %s\n", type); |
|
1110 |
- |
|
1102 |
+ ftype_bits(type, si.filetype); |
|
1111 | 1103 |
si.cbSize = sizeof(si); |
1112 | 1104 |
si.flags = 0; |
1113 | 1105 |
si.scanPhase = (fd == sctx->entryfd) ? SCAN_PHASE_INITIAL : SCAN_PHASE_PRESCAN; |