git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@781 77e5149b-7576-45b1-b177-96237e5ba77b
Nigel Horne authored on 2004/08/23 00:10:32... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Sun Aug 22 16:09:30 BST 2004 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav: Early save to disc is now compatible with FOLLOWURLS |
|
4 |
+ |
|
1 | 5 |
Sun Aug 22 14:18:53 CEST 2004 (tk) |
2 | 6 |
---------------------------------- |
3 | 7 |
* libclamav: cli_scanhtml: Respect file size limit |
... | ... |
@@ -16,6 +16,9 @@ |
16 | 16 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
17 | 17 |
* |
18 | 18 |
* $Log: blob.c,v $ |
19 |
+ * Revision 1.16 2004/08/22 15:08:58 nigelhorne |
|
20 |
+ * messageExport |
|
21 |
+ * |
|
19 | 22 |
* Revision 1.15 2004/08/22 10:34:24 nigelhorne |
20 | 23 |
* Use fileblob |
21 | 24 |
* |
... | ... |
@@ -47,7 +50,7 @@ |
47 | 47 |
* Change LOG to Log |
48 | 48 |
* |
49 | 49 |
*/ |
50 |
-static char const rcsid[] = "$Id: blob.c,v 1.15 2004/08/22 10:34:24 nigelhorne Exp $"; |
|
50 |
+static char const rcsid[] = "$Id: blob.c,v 1.16 2004/08/22 15:08:58 nigelhorne Exp $"; |
|
51 | 51 |
|
52 | 52 |
#if HAVE_CONFIG_H |
53 | 53 |
#include "clamav-config.h" |
... | ... |
@@ -122,8 +125,9 @@ blobArrayDestroy(blob *blobList[], int n) |
122 | 122 |
} |
123 | 123 |
} |
124 | 124 |
|
125 |
+/*ARGSUSED*/ |
|
125 | 126 |
void |
126 |
-blobSetFilename(blob *b, const char *filename) |
|
127 |
+blobSetFilename(blob *b, const char *dir, const char *filename) |
|
127 | 128 |
{ |
128 | 129 |
assert(b != NULL); |
129 | 130 |
assert(b->magic == BLOB); |
... | ... |
@@ -356,7 +360,7 @@ fileblobSetFilename(fileblob *fb, const char *dir, const char *filename) |
356 | 356 |
suffixLen = 0; |
357 | 357 |
} |
358 | 358 |
} |
359 |
- blobSetFilename(&fb->b, filename); |
|
359 |
+ blobSetFilename(&fb->b, dir, filename); |
|
360 | 360 |
|
361 | 361 |
/* |
362 | 362 |
* Reload the filename, it may be different from the one we've |
... | ... |
@@ -38,7 +38,7 @@ typedef struct blob { |
38 | 38 |
blob *blobCreate(void); |
39 | 39 |
void blobDestroy(blob *b); |
40 | 40 |
void blobArrayDestroy(blob *b[], int n); |
41 |
-void blobSetFilename(blob *b, const char *filename); |
|
41 |
+void blobSetFilename(blob *b, const char *dir, const char *filename); |
|
42 | 42 |
const char *blobGetFilename(const blob *b); |
43 | 43 |
void blobAddData(blob *b, const unsigned char *data, size_t len); |
44 | 44 |
unsigned char *blobGetData(const blob *b); |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: mbox.c,v $ |
20 |
+ * Revision 1.110 2004/08/22 15:08:59 nigelhorne |
|
21 |
+ * messageExport |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.109 2004/08/22 10:34:24 nigelhorne |
21 | 24 |
* Use fileblob |
22 | 25 |
* |
... | ... |
@@ -315,7 +318,7 @@ |
315 | 315 |
* Compilable under SCO; removed duplicate code with message.c |
316 | 316 |
* |
317 | 317 |
*/ |
318 |
-static char const rcsid[] = "$Id: mbox.c,v 1.109 2004/08/22 10:34:24 nigelhorne Exp $"; |
|
318 |
+static char const rcsid[] = "$Id: mbox.c,v 1.110 2004/08/22 15:08:59 nigelhorne Exp $"; |
|
319 | 319 |
|
320 | 320 |
#if HAVE_CONFIG_H |
321 | 321 |
#include "clamav-config.h" |
... | ... |
@@ -1349,6 +1352,7 @@ parseEmailBody(message *messageIn, blob **blobsIn, int nBlobs, text *textIn, con |
1349 | 1349 |
if(mainMessage && (mainMessage != messageIn)) |
1350 | 1350 |
messageDestroy(mainMessage); |
1351 | 1351 |
mainMessage = NULL; |
1352 |
+ cli_dbgmsg("Mime subtype \"%s\"\n", cptr); |
|
1352 | 1353 |
if(u_line) { |
1353 | 1354 |
cli_dbgmsg("Found uuencoded message in multipart/mixed text portion\n"); |
1354 | 1355 |
messageSetEncoding(aMessage, "x-uuencode"); |
... | ... |
@@ -17,6 +17,9 @@ |
17 | 17 |
* |
18 | 18 |
* Change History: |
19 | 19 |
* $Log: message.c,v $ |
20 |
+ * Revision 1.74 2004/08/22 15:08:59 nigelhorne |
|
21 |
+ * messageExport |
|
22 |
+ * |
|
20 | 23 |
* Revision 1.73 2004/08/22 10:34:24 nigelhorne |
21 | 24 |
* Use fileblob |
22 | 25 |
* |
... | ... |
@@ -216,7 +219,7 @@ |
216 | 216 |
* uuencodebegin() no longer static |
217 | 217 |
* |
218 | 218 |
*/ |
219 |
-static char const rcsid[] = "$Id: message.c,v 1.73 2004/08/22 10:34:24 nigelhorne Exp $"; |
|
219 |
+static char const rcsid[] = "$Id: message.c,v 1.74 2004/08/22 15:08:59 nigelhorne Exp $"; |
|
220 | 220 |
|
221 | 221 |
#if HAVE_CONFIG_H |
222 | 222 |
#include "clamav-config.h" |
... | ... |
@@ -973,21 +976,20 @@ messageClean(message *m) |
973 | 973 |
} |
974 | 974 |
|
975 | 975 |
/* |
976 |
- * Decode and transfer the contents of the message into a blob |
|
977 |
- * The caller must free the returned blob |
|
976 |
+ * Export a message using the given export routines |
|
978 | 977 |
*/ |
979 |
-fileblob * |
|
980 |
-messageToFileblob(message *m, const char *dir) |
|
978 |
+void * |
|
979 |
+messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy)(void *), void (*setFilename)(void *, const char *, const char *), void (*addData)(void *, const unsigned char *, size_t), void *(*exportText)(const text *, void *)) |
|
981 | 980 |
{ |
982 |
- fileblob *fb; |
|
981 |
+ void *ret; |
|
983 | 982 |
const text *t_line = NULL; |
984 | 983 |
char *filename; |
985 | 984 |
|
986 | 985 |
assert(m != NULL); |
987 | 986 |
|
988 |
- fb = fileblobCreate(); |
|
987 |
+ ret = (*create)(); |
|
989 | 988 |
|
990 |
- if(fb == NULL) |
|
989 |
+ if(ret == NULL) |
|
991 | 990 |
return NULL; |
992 | 991 |
|
993 | 992 |
/* |
... | ... |
@@ -998,7 +1000,7 @@ messageToFileblob(message *m, const char *dir) |
998 | 998 |
|
999 | 999 |
if(t_line == NULL) { |
1000 | 1000 |
/*cli_warnmsg("UUENCODED attachment is missing begin statement\n");*/ |
1001 |
- fileblobDestroy(fb); |
|
1001 |
+ (*destroy)(ret); |
|
1002 | 1002 |
return NULL; |
1003 | 1003 |
} |
1004 | 1004 |
|
... | ... |
@@ -1006,14 +1008,14 @@ messageToFileblob(message *m, const char *dir) |
1006 | 1006 |
|
1007 | 1007 |
if(filename == NULL) { |
1008 | 1008 |
cli_dbgmsg("UUencoded attachment sent with no filename\n"); |
1009 |
- fileblobDestroy(fb); |
|
1009 |
+ (*destroy)(ret); |
|
1010 | 1010 |
return NULL; |
1011 | 1011 |
} |
1012 | 1012 |
cli_chomp(filename); |
1013 | 1013 |
|
1014 | 1014 |
cli_dbgmsg("Set uuencode filename to \"%s\"\n", filename); |
1015 | 1015 |
|
1016 |
- fileblobSetFilename(fb, dir, filename); |
|
1016 |
+ (*setFilename)(ret, dir, filename); |
|
1017 | 1017 |
t_line = t_line->t_next; |
1018 | 1018 |
} else if((t_line = binhexBegin(m)) != NULL) { |
1019 | 1019 |
unsigned char byte; |
... | ... |
@@ -1042,7 +1044,7 @@ messageToFileblob(message *m, const char *dir) |
1042 | 1042 |
tmp = blobCreate(); |
1043 | 1043 |
|
1044 | 1044 |
if(tmp == NULL) { |
1045 |
- fileblobDestroy(fb); |
|
1045 |
+ (*destroy)(ret); |
|
1046 | 1046 |
return NULL; |
1047 | 1047 |
} |
1048 | 1048 |
|
... | ... |
@@ -1064,7 +1066,7 @@ messageToFileblob(message *m, const char *dir) |
1064 | 1064 |
if(data == NULL) { |
1065 | 1065 |
cli_warnmsg("Couldn't locate the binhex message that was claimed to be there\n"); |
1066 | 1066 |
blobDestroy(tmp); |
1067 |
- fileblobDestroy(fb); |
|
1067 |
+ (*destroy)(ret); |
|
1068 | 1068 |
return NULL; |
1069 | 1069 |
} |
1070 | 1070 |
if(data[0] != ':') { |
... | ... |
@@ -1075,7 +1077,7 @@ messageToFileblob(message *m, const char *dir) |
1075 | 1075 |
*/ |
1076 | 1076 |
cli_warnmsg("8 bit binhex code is not yet supported\n"); |
1077 | 1077 |
blobDestroy(tmp); |
1078 |
- fileblobDestroy(fb); |
|
1078 |
+ (*destroy)(ret); |
|
1079 | 1079 |
return NULL; |
1080 | 1080 |
} |
1081 | 1081 |
|
... | ... |
@@ -1092,7 +1094,7 @@ messageToFileblob(message *m, const char *dir) |
1092 | 1092 |
uptr = cli_malloc(len); |
1093 | 1093 |
if(uptr == NULL) { |
1094 | 1094 |
blobDestroy(tmp); |
1095 |
- fileblobDestroy(fb); |
|
1095 |
+ (*destroy)(ret); |
|
1096 | 1096 |
return NULL; |
1097 | 1097 |
} |
1098 | 1098 |
memcpy(uptr, data, len); |
... | ... |
@@ -1161,7 +1163,7 @@ messageToFileblob(message *m, const char *dir) |
1161 | 1161 |
blob *u = blobCreate(); /* uncompressed data */ |
1162 | 1162 |
|
1163 | 1163 |
if(u == NULL) { |
1164 |
- fileblobDestroy(fb); |
|
1164 |
+ (*destroy)(ret); |
|
1165 | 1165 |
blobDestroy(tmp); |
1166 | 1166 |
return NULL; |
1167 | 1167 |
} |
... | ... |
@@ -1208,7 +1210,7 @@ messageToFileblob(message *m, const char *dir) |
1208 | 1208 |
} |
1209 | 1209 |
if(len == 0) { |
1210 | 1210 |
cli_warnmsg("Discarding empty binHex attachment\n"); |
1211 |
- fileblobDestroy(fb); |
|
1211 |
+ (*destroy)(ret); |
|
1212 | 1212 |
blobDestroy(tmp); |
1213 | 1213 |
return NULL; |
1214 | 1214 |
} |
... | ... |
@@ -1225,19 +1227,19 @@ messageToFileblob(message *m, const char *dir) |
1225 | 1225 |
*/ |
1226 | 1226 |
byte = data[0]; |
1227 | 1227 |
if(byte >= len) { |
1228 |
- fileblobDestroy(fb); |
|
1228 |
+ (*destroy)(ret); |
|
1229 | 1229 |
blobDestroy(tmp); |
1230 | 1230 |
return NULL; |
1231 | 1231 |
} |
1232 | 1232 |
filename = cli_malloc(byte + 1); |
1233 | 1233 |
if(filename == NULL) { |
1234 |
- fileblobDestroy(fb); |
|
1234 |
+ (*destroy)(ret); |
|
1235 | 1235 |
blobDestroy(tmp); |
1236 | 1236 |
return NULL; |
1237 | 1237 |
} |
1238 | 1238 |
memcpy(filename, &data[1], byte); |
1239 | 1239 |
filename[byte] = '\0'; |
1240 |
- fileblobSetFilename(fb, dir, filename); |
|
1240 |
+ (*setFilename)(ret, dir, filename); |
|
1241 | 1241 |
/*ptr = cli_malloc(strlen(filename) + 6);*/ |
1242 | 1242 |
ptr = cli_malloc(byte + 6); |
1243 | 1243 |
if(ptr) { |
... | ... |
@@ -1276,11 +1278,11 @@ messageToFileblob(message *m, const char *dir) |
1276 | 1276 |
len, l); |
1277 | 1277 |
len = l; |
1278 | 1278 |
} |
1279 |
- fileblobAddData(fb, &data[byte], len); |
|
1279 |
+ (*addData)(ret, &data[byte], len); |
|
1280 | 1280 |
|
1281 | 1281 |
blobDestroy(tmp); |
1282 | 1282 |
|
1283 |
- return fb; |
|
1283 |
+ return ret; |
|
1284 | 1284 |
} else { |
1285 | 1285 |
filename = (char *)messageFindArgument(m, "filename"); |
1286 | 1286 |
if(filename == NULL) { |
... | ... |
@@ -1298,7 +1300,7 @@ messageToFileblob(message *m, const char *dir) |
1298 | 1298 |
messageSetEncoding(m, "base64"); |
1299 | 1299 |
} |
1300 | 1300 |
|
1301 |
- fileblobSetFilename(fb, dir, filename); |
|
1301 |
+ (*setFilename)(ret, dir, filename); |
|
1302 | 1302 |
|
1303 | 1303 |
t_line = messageGetBody(m); |
1304 | 1304 |
} |
... | ... |
@@ -1309,7 +1311,7 @@ messageToFileblob(message *m, const char *dir) |
1309 | 1309 |
*/ |
1310 | 1310 |
if(t_line == NULL) { |
1311 | 1311 |
cli_warnmsg("Empty attachment not saved\n"); |
1312 |
- fileblobDestroy(fb); |
|
1312 |
+ (*destroy)(ret); |
|
1313 | 1313 |
return NULL; |
1314 | 1314 |
} |
1315 | 1315 |
|
... | ... |
@@ -1317,7 +1319,7 @@ messageToFileblob(message *m, const char *dir) |
1317 | 1317 |
/* |
1318 | 1318 |
* Fast copy |
1319 | 1319 |
*/ |
1320 |
- return textToFileblob(t_line, fb); |
|
1320 |
+ return exportText(t_line, ret); |
|
1321 | 1321 |
|
1322 | 1322 |
do { |
1323 | 1323 |
unsigned char data[1024]; |
... | ... |
@@ -1342,7 +1344,7 @@ messageToFileblob(message *m, const char *dir) |
1342 | 1342 |
assert(uptr <= &data[sizeof(data)]); |
1343 | 1343 |
|
1344 | 1344 |
if(uptr != data) |
1345 |
- fileblobAddData(fb, data, (size_t)(uptr - data)); |
|
1345 |
+ (*addData)(ret, data, (size_t)(uptr - data)); |
|
1346 | 1346 |
|
1347 | 1347 |
/* |
1348 | 1348 |
* According to RFC1521, '=' is used to pad out |
... | ... |
@@ -1364,11 +1366,32 @@ messageToFileblob(message *m, const char *dir) |
1364 | 1364 |
|
1365 | 1365 |
ptr = decode(m, NULL, data, base64, FALSE); |
1366 | 1366 |
if(ptr) |
1367 |
- fileblobAddData(fb, data, (size_t)(ptr - data)); |
|
1367 |
+ (*addData)(ret, data, (size_t)(ptr - data)); |
|
1368 | 1368 |
m->base64chars = 0; |
1369 | 1369 |
} |
1370 | 1370 |
|
1371 |
- return fb; |
|
1371 |
+ return ret; |
|
1372 |
+} |
|
1373 |
+ |
|
1374 |
+/* |
|
1375 |
+ * Decode and transfer the contents of the message into a fileblob |
|
1376 |
+ * The caller must free the returned fileblob |
|
1377 |
+ */ |
|
1378 |
+fileblob * |
|
1379 |
+messageToFileblob(message *m, const char *dir) |
|
1380 |
+{ |
|
1381 |
+ return messageExport(m, dir, fileblobCreate, fileblobDestroy, fileblobSetFilename, fileblobAddData, textToFileblob); |
|
1382 |
+} |
|
1383 |
+ |
|
1384 |
+/* |
|
1385 |
+ * Decode and transfer the contents of the message into a blob |
|
1386 |
+ * The caller must free the returned blob |
|
1387 |
+ * TODO: a lot of code here is duplicated with messageToFileblob |
|
1388 |
+ */ |
|
1389 |
+blob * |
|
1390 |
+messageToBlob(message *m) |
|
1391 |
+{ |
|
1392 |
+ return messageExport(m, NULL, blobCreate, blobDestroy, blobSetFilename, blobAddData, textToBlob); |
|
1372 | 1393 |
} |
1373 | 1394 |
|
1374 | 1395 |
/* |
... | ... |
@@ -16,6 +16,9 @@ |
16 | 16 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
17 | 17 |
* |
18 | 18 |
* $Log: message.h,v $ |
19 |
+ * Revision 1.15 2004/08/22 15:08:59 nigelhorne |
|
20 |
+ * messageExport |
|
21 |
+ * |
|
19 | 22 |
* Revision 1.14 2004/08/22 10:34:24 nigelhorne |
20 | 23 |
* Use fileblob |
21 | 24 |
* |
... | ... |
@@ -94,7 +97,9 @@ int messageAddStr(message *m, const char *data); |
94 | 94 |
int messageAddStrAtTop(message *m, const char *data); |
95 | 95 |
const text *messageGetBody(const message *m); |
96 | 96 |
void messageClean(message *m); |
97 |
+void *messageExport(message *m, const char *dir, void *(*create)(void), void (*destroy)(void *), void (*setFilename)(void *, const char *, const char *), void (*addData)(void *, const unsigned char *, size_t), void *(*exportText)(const text *, void *)); |
|
97 | 98 |
fileblob *messageToFileblob(message *m, const char *dir); |
99 |
+blob *messageToBlob(message *m); |
|
98 | 100 |
text *messageToText(message *m); |
99 | 101 |
const text *uuencodeBegin(const message *m); |
100 | 102 |
const text *binhexBegin(const message *m); |