Browse code

Downgrade warning to debug

git-svn: trunk@1366

Nigel Horne authored on 2005/03/03 05:08:24
Showing 1 changed files
... ...
@@ -14,647 +14,8 @@
14 14
  *  You should have received a copy of the GNU General Public License
15 15
  *  along with this program; if not, write to the Free Software
16 16
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
- *
18
- * Change History:
19
- * $Log: mbox.c,v $
20
- * Revision 1.222  2005/02/18 18:00:55  nigelhorne
21
- * Save separate bounces in separate files
22
- *
23
- * Revision 1.221  2005/02/17 19:36:08  nigelhorne
24
- * Fix minor typo with bounce handlers
25
- *
26
- * Revision 1.220  2005/02/17 19:06:32  nigelhorne
27
- * Prescan bounces
28
- *
29
- * Revision 1.219  2005/02/16 22:20:49  nigelhorne
30
- * New code now called NEW_WORLD
31
- *
32
- * Revision 1.218  2005/02/06 18:21:18  nigelhorne
33
- * Some W95.Matrix.SCR were not being found
34
- *
35
- * Revision 1.217  2005/02/06 09:45:53  nigelhorne
36
- * Speed up the (not implemented) next generation of mbox code
37
- *
38
- * Revision 1.216  2005/02/06 09:21:55  nigelhorne
39
- * Better check for boundaries with comments
40
- *
41
- * Revision 1.215  2005/02/03 21:07:33  nigelhorne
42
- * Faster handling of bounce messages
43
- *
44
- * Revision 1.214  2005/02/01 14:46:06  nigelhorne
45
- * Decode encapsulated bounce messages that have been base64 encoded (needlessly :-) )
46
- *
47
- * Revision 1.213  2005/01/31 11:02:43  nigelhorne
48
- * Handle blank lines in multipart headers
49
- *
50
- * Revision 1.212  2005/01/27 14:10:53  nigelhorne
51
- * Scan sendmail queue df files
52
- *
53
- * Revision 1.211  2005/01/19 17:41:25  nigelhorne
54
- * Downgraded warning message
55
- *
56
- * Revision 1.210  2005/01/09 21:23:21  nigelhorne
57
- * Catch HTML.Phishing.Bank-41
58
- *
59
- * Revision 1.209  2005/01/09 11:37:02  nigelhorne
60
- * Handle broken RFC2047 headers
61
- *
62
- * Revision 1.208  2005/01/07 13:48:46  nigelhorne
63
- * Save content-type: application only once
64
- *
65
- * Revision 1.207  2005/01/06 23:21:34  nigelhorne
66
- * Improved handling of quotes over multiple lines in headers
67
- *
68
- * Revision 1.206  2005/01/06 11:53:29  nigelhorne
69
- * Handle bounces in non mime encoded messages
70
- *
71
- * Revision 1.205  2005/01/01 15:55:26  nigelhorne
72
- * Changes handling of unbalanced quotes in multipart headers
73
- *
74
- * Revision 1.204  2004/12/19 23:19:54  nigelhorne
75
- * Tidy
76
- *
77
- * Revision 1.203  2004/12/19 13:50:08  nigelhorne
78
- * Tidy
79
- *
80
- * Revision 1.202  2004/12/18 16:32:10  nigelhorne
81
- * Added parseEmailFile
82
- *
83
- * Revision 1.201  2004/12/16 15:29:08  nigelhorne
84
- * Tidy and add mmap test code
85
- *
86
- * Revision 1.200  2004/12/07 23:08:10  nigelhorne
87
- * Fix empty content-type in multipart header
88
- *
89
- * Revision 1.199  2004/12/07 09:01:24  nigelhorne
90
- * Tidy
91
- *
92
- * Revision 1.198  2004/12/04 16:03:55  nigelhorne
93
- * Text/plain now handled as no encoding
94
- *
95
- * Revision 1.197  2004/12/04 15:50:39  nigelhorne
96
- * Handle text/rfc822-headers incorrectly sent as message/rfc822-headers
97
- *
98
- * Revision 1.196  2004/12/01 13:12:35  nigelhorne
99
- * Decode text/plain parts marked as being encoded
100
- *
101
- * Revision 1.195  2004/11/29 13:21:20  nigelhorne
102
- * Remove the old continuation marker method
103
- *
104
- * Revision 1.194  2004/11/28 22:06:38  nigelhorne
105
- * Tidy space only headers code
106
- *
107
- * Revision 1.193  2004/11/28 21:05:50  nigelhorne
108
- * Handle headers with only spaces
109
- *
110
- * Revision 1.192  2004/11/28 16:27:28  nigelhorne
111
- * Save the text portions as text not mail files
112
- *
113
- * Revision 1.191  2004/11/27 21:55:06  nigelhorne
114
- * Changed some more strtok to cli_strtok
115
- *
116
- * Revision 1.190  2004/11/27 14:49:13  nigelhorne
117
- * Use a static array for the partial directory
118
- *
119
- * Revision 1.189  2004/11/27 14:39:01  nigelhorne
120
- * Honour section 7.2.6 of RFC1521
121
- *
122
- * Revision 1.188  2004/11/27 14:17:35  nigelhorne
123
- * Handle attachments before the first mime section
124
- *
125
- * Revision 1.187  2004/11/27 13:16:56  nigelhorne
126
- * uuencode failures no longer fatal
127
- *
128
- * Revision 1.186  2004/11/27 11:59:28  nigelhorne
129
- * Handle comments in the command part of headers
130
- *
131
- * Revision 1.185  2004/11/26 23:00:29  nigelhorne
132
- * Handle spaces after the final MIME boundary and binHex attachments after that boundary
133
- *
134
- * Revision 1.184  2004/11/26 21:51:48  nigelhorne
135
- * Scan uuencodes after the final MIME section
136
- *
137
- * Revision 1.183  2004/11/26 17:32:42  nigelhorne
138
- * Add debug message for end of multipart headers
139
- *
140
- * Revision 1.182  2004/11/26 12:05:17  nigelhorne
141
- * Remove warning message
142
- *
143
- * Revision 1.181  2004/11/22 15:18:51  nigelhorne
144
- * Performance work
145
- *
146
- * Revision 1.180  2004/11/19 11:32:16  nigelhorne
147
- * Scan email footers (portions after the last MIME boundary
148
- *
149
- * Revision 1.179  2004/11/18 18:09:07  nigelhorne
150
- * First draft of binhex.c
151
- *
152
- * Revision 1.178  2004/11/15 13:58:50  nigelhorne
153
- * Fix obscure chance of memory leak
154
- *
155
- * Revision 1.177  2004/11/12 22:22:21  nigelhorne
156
- * Performance speeded up
157
- *
158
- * Revision 1.176  2004/11/12 09:41:45  nigelhorne
159
- * Parial mode now on by default
160
- *
161
- * Revision 1.175  2004/11/11 22:15:46  nigelhorne
162
- * Rewrite handling of folded headers
163
- *
164
- * Revision 1.174  2004/11/10 10:08:45  nigelhorne
165
- * Fix escaped parenthesis in rfc822 comments
166
- *
167
- * Revision 1.173  2004/11/09 19:40:06  nigelhorne
168
- * Find uuencoded files in preambles to multipart messages
169
- *
170
- * Revision 1.172  2004/11/09 13:33:38  nigelhorne
171
- * Tidy
172
- *
173
- * Revision 1.171  2004/11/09 12:24:32  nigelhorne
174
- * Better handling of mail-follow-urls when CURL is not installed
175
- *
176
- * Revision 1.170  2004/11/09 10:08:02  nigelhorne
177
- * Added basic handling of folded headers in the main message
178
- *
179
- * Revision 1.169  2004/11/08 16:27:09  nigelhorne
180
- * Fix crash with correctly encoded uuencode files
181
- *
182
- * Revision 1.168  2004/11/08 10:26:22  nigelhorne
183
- * Fix crash if x-yencode is mistakenly guessed
184
- *
185
- * Revision 1.167  2004/11/07 16:59:42  nigelhorne
186
- * Tidy
187
- *
188
- * Revision 1.166  2004/11/07 16:39:00  nigelhorne
189
- * Handle para 4 of RFC2231
190
- *
191
- * Revision 1.165  2004/11/06 21:43:23  nigelhorne
192
- * Fix possible segfault in handling broken RFC2047 headers
193
- *
194
- * Revision 1.164  2004/11/04 10:13:41  nigelhorne
195
- * Rehashed readdir_r patch
196
- *
197
- * Revision 1.163  2004/10/31 09:28:56  nigelhorne
198
- * Handle unbalanced quotes in multipart headers
199
- *
200
- * Revision 1.162  2004/10/24 04:35:15  nigelhorne
201
- * Handle multipart/knowbot as multipart/mixed
202
- *
203
- * Revision 1.161  2004/10/21 10:18:40  nigelhorne
204
- * PARTIAL: readdir_r even more options :-(
205
- *
206
- * Revision 1.160  2004/10/21 09:41:07  nigelhorne
207
- * PARTIAL: add readdir_r fix to BeOS
208
- *
209
- * Revision 1.159  2004/10/20 10:35:41  nigelhorne
210
- * Partial mode: fix possible stack corruption with Solaris
211
- *
212
- * Revision 1.158  2004/10/17 09:29:21  nigelhorne
213
- * Advise to report broken emails
214
- *
215
- * Revision 1.157  2004/10/16 20:53:28  nigelhorne
216
- * Tidy up
217
- *
218
- * Revision 1.156  2004/10/16 19:09:39  nigelhorne
219
- * Handle BeMail (BeOS) files
220
- *
221
- * Revision 1.155  2004/10/16 17:23:04  nigelhorne
222
- * Handle colons in quotes in headers
223
- *
224
- * Revision 1.154  2004/10/16 09:01:05  nigelhorne
225
- * Improved handling of wraparound headers
226
- *
227
- * Revision 1.153  2004/10/14 21:18:49  nigelhorne
228
- * Harden the test for RFC2047 encoded headers
229
- *
230
- * Revision 1.152  2004/10/14 17:45:13  nigelhorne
231
- * RFC2047 on long lines produced by continuation headers
232
- *
233
- * Revision 1.151  2004/10/10 11:10:20  nigelhorne
234
- * Remove perror - replace with cli_errmsg
235
- *
236
- * Revision 1.150  2004/10/09 08:01:37  nigelhorne
237
- * Needs libcurl >= 7.11
238
- *
239
- * Revision 1.149  2004/10/06 17:21:30  nigelhorne
240
- * Fix RFC2298 handling broken by RFC1341 code
241
- *
242
- * Revision 1.148  2004/10/05 15:41:53  nigelhorne
243
- * First draft of code to handle RFC1341
244
- *
245
- * Revision 1.147  2004/10/04 12:18:09  nigelhorne
246
- * Better warning message about PGP attachments not being scanned
247
- *
248
- * Revision 1.146  2004/10/04 10:52:39  nigelhorne
249
- * Better error message on RFC2047 decode error
250
- *
251
- * Revision 1.145  2004/10/01 13:49:22  nigelhorne
252
- * Minor code tidy
253
- *
254
- * Revision 1.144  2004/10/01 07:55:36  nigelhorne
255
- * Better error message on message/partial
256
- *
257
- * Revision 1.143  2004/09/30 21:47:35  nigelhorne
258
- * Removed unneeded strdups
259
- *
260
- * Revision 1.142  2004/09/28 18:40:12  nigelhorne
261
- * Use stack rather than heap where possible
262
- *
263
- * Revision 1.141  2004/09/23 08:43:25  nigelhorne
264
- * Scan multipart/digest messages
265
- *
266
- * Revision 1.140  2004/09/22 16:09:51  nigelhorne
267
- * Build if CURLOPT_DNS_USE_GLOBAL_CACHE isn't supported
268
- *
269
- * Revision 1.139  2004/09/22 15:49:13  nigelhorne
270
- * Handle RFC2298 messages
271
- *
272
- * Revision 1.138  2004/09/22 15:21:50  nigelhorne
273
- * Fix typo
274
- *
275
- * Revision 1.137  2004/09/21 20:47:38  nigelhorne
276
- * FOLLOWURL: Set a default username and password for password protected pages
277
- *
278
- * Revision 1.136  2004/09/21 12:18:52  nigelhorne
279
- * Fallback to CURLOPT_FILE if CURLOPT_WRITEDATA isn't defined
280
- *
281
- * Revision 1.135  2004/09/21 08:14:00  nigelhorne
282
- * Now compiles in machines with libcurl but without threads
283
- *
284
- * Revision 1.134  2004/09/20 17:08:43  nigelhorne
285
- * Some performance enhancements
286
- *
287
- * Revision 1.133  2004/09/20 12:44:03  nigelhorne
288
- * Fix parsing error on mime arguments
289
- *
290
- * Revision 1.132  2004/09/20 08:31:56  nigelhorne
291
- * FOLLOWURLS now compiled if libcurl is found
292
- *
293
- * Revision 1.131  2004/09/18 14:59:25  nigelhorne
294
- * Code tidy
295
- *
296
- * Revision 1.130  2004/09/17 10:56:29  nigelhorne
297
- * Handle multiple content-type headers and use the most likely
298
- *
299
- * Revision 1.129  2004/09/17 09:48:53  nigelhorne
300
- * Handle attempts to hide mime type
301
- *
302
- * Revision 1.128  2004/09/17 09:09:44  nigelhorne
303
- * Better handling of RFC822 comments
304
- *
305
- * Revision 1.127  2004/09/16 18:00:43  nigelhorne
306
- * Handle RFC2047
307
- *
308
- * Revision 1.126  2004/09/16 14:23:57  nigelhorne
309
- * Handle quotes around mime type
310
- *
311
- * Revision 1.125  2004/09/16 12:59:36  nigelhorne
312
- * Handle = and space as header separaters
313
- *
314
- * Revision 1.124  2004/09/16 11:20:33  nigelhorne
315
- * Better handling of folded headers in multipart messages
316
- *
317
- * Revision 1.123  2004/09/16 08:56:19  nigelhorne
318
- * Handle RFC822 Comments
319
- *
320
- * Revision 1.122  2004/09/15 22:09:26  nigelhorne
321
- * Handle spaces before colons
322
- *
323
- * Revision 1.121  2004/09/15 18:08:23  nigelhorne
324
- * Handle multiple encoding types
325
- *
326
- * Revision 1.120  2004/09/15 08:47:07  nigelhorne
327
- * Cleaner way to initialise hrefs
328
- *
329
- * Revision 1.119  2004/09/14 20:47:28  nigelhorne
330
- * Use new normalise code
331
- *
332
- * Revision 1.118  2004/09/14 12:09:37  nigelhorne
333
- * Include old normalise code
334
- *
335
- * Revision 1.117  2004/09/13 16:44:01  kojm
336
- * minor cleanup
337
- *
338
- * Revision 1.116  2004/09/13 13:16:28  nigelhorne
339
- * Return CL_EFORMAT on bad format
340
- *
341
- * Revision 1.115  2004/09/06 11:02:08  nigelhorne
342
- * Normalise HTML before scanning for URLs to download
343
- *
344
- * Revision 1.114  2004/09/03 15:59:00  nigelhorne
345
- * Handle boundary= "foo"
346
- *
347
- * Revision 1.113  2004/08/26 09:33:20  nigelhorne
348
- * Scan Communigate Pro files
349
- *
350
- * Revision 1.112  2004/08/23 13:15:16  nigelhorne
351
- * messageClearMarkers
352
- *
353
- * Revision 1.111  2004/08/22 20:20:14  nigelhorne
354
- * Tidy
355
- *
356
- * Revision 1.110  2004/08/22 15:08:59  nigelhorne
357
- * messageExport
358
- *
359
- * Revision 1.109  2004/08/22 10:34:24  nigelhorne
360
- * Use fileblob
361
- *
362
- * Revision 1.108  2004/08/21 11:57:57  nigelhorne
363
- * Use line.[ch]
364
- *
365
- * Revision 1.107  2004/08/20 04:55:07  nigelhorne
366
- * FOLLOWURL
367
- *
368
- * Revision 1.106  2004/08/20 04:53:18  nigelhorne
369
- * Tidy up
370
- *
371
- * Revision 1.105  2004/08/18 21:35:08  nigelhorne
372
- * Multithread the FollowURL calls
373
- *
374
- * Revision 1.104  2004/08/18 15:53:43  nigelhorne
375
- * Honour CL_MAILURL
376
- *
377
- * Revision 1.103  2004/08/18 10:49:45  nigelhorne
378
- * CHECKURLs was mistakenly turned on
379
- *
380
- * Revision 1.102  2004/08/18 07:45:20  nigelhorne
381
- * Use configure WITH_CURL value
382
- *
383
- * Revision 1.101  2004/08/17 08:28:32  nigelhorne
384
- * Support multitype/fax-message
385
- *
386
- * Revision 1.100  2004/08/12 10:36:09  nigelhorne
387
- * LIBCURL completed
388
- *
389
- * Revision 1.99  2004/08/11 15:28:39  nigelhorne
390
- * No longer needs curl.h
391
- *
392
- * Revision 1.98  2004/08/11 14:46:22  nigelhorne
393
- * Better handling of false positive emails
394
- *
395
- * Revision 1.97  2004/08/10 14:02:22  nigelhorne
396
- * *** empty log message ***
397
- *
398
- * Revision 1.96  2004/08/10 08:14:00  nigelhorne
399
- * Enable CHECKURL
400
- *
401
- * Revision 1.95  2004/08/09 21:37:21  kojm
402
- * libclamav: add new option CL_MAILURL
403
- *
404
- * Revision 1.94  2004/08/09 08:26:36  nigelhorne
405
- * Thread safe checkURL
406
- *
407
- * Revision 1.93  2004/08/08 21:30:47  nigelhorne
408
- * First draft of CheckURL
409
- *
410
- * Revision 1.92  2004/08/08 19:13:14  nigelhorne
411
- * Better handling of bounces
412
- *
413
- * Revision 1.91  2004/08/04 18:59:19  nigelhorne
414
- * Tidy up multipart handling
415
- *
416
- * Revision 1.90  2004/07/26 17:02:56  nigelhorne
417
- * Fix crash when debugging on SPARC
418
- *
419
- * Revision 1.89  2004/07/26 09:12:12  nigelhorne
420
- * Fix crash when debugging on Solaris
421
- *
422
- * Revision 1.88  2004/07/20 14:35:29  nigelhorne
423
- * Some MYDOOM.I were getting through
424
- *
425
- * Revision 1.87  2004/07/19 17:54:40  kojm
426
- * Use new patter matching algorithm. Cleanup.
427
- *
428
- * Revision 1.86  2004/07/06 09:32:45  nigelhorne
429
- * Better handling of Gibe.3 boundary exploit
430
- *
431
- * Revision 1.85  2004/06/30 19:48:58  nigelhorne
432
- * Some TR.Happy99.SKA were getting through
433
- *
434
- * Revision 1.84  2004/06/30 14:30:40  nigelhorne
435
- * Fix compilation error on Solaris
436
- *
437
- * Revision 1.83  2004/06/28 11:44:45  nigelhorne
438
- * Remove empty parts
439
- *
440
- * Revision 1.82  2004/06/25 13:56:38  nigelhorne
441
- * Optimise messages without other messages encapsulated within them
442
- *
443
- * Revision 1.81  2004/06/24 21:36:38  nigelhorne
444
- * Plug memory leak with large number of attachments
445
- *
446
- * Revision 1.80  2004/06/23 16:23:25  nigelhorne
447
- * Further empty line optimisation
448
- *
449
- * Revision 1.79  2004/06/22 04:08:01  nigelhorne
450
- * Optimise empty lines
451
- *
452
- * Revision 1.78  2004/06/21 10:21:19  nigelhorne
453
- * Fix crash when a multipart/mixed message contains many parts that need to be scanned as attachments
454
- *
455
- * Revision 1.77  2004/06/18 10:07:12  nigelhorne
456
- * Allow any number of alternatives in multipart messages
457
- *
458
- * Revision 1.76  2004/06/16 08:07:39  nigelhorne
459
- * Added thread safety
460
- *
461
- * Revision 1.75  2004/06/14 09:07:10  nigelhorne
462
- * Handle spam using broken e-mail generators for multipart/alternative
463
- *
464
- * Revision 1.74  2004/06/09 18:18:59  nigelhorne
465
- * Find uuencoded viruses in multipart/mixed that have no start of message boundaries
466
- *
467
- * Revision 1.73  2004/05/14 08:15:55  nigelhorne
468
- * Use mkstemp on cygwin
469
- *
470
- * Revision 1.72  2004/05/12 11:20:37  nigelhorne
471
- * More bounce message false positives handled
472
- *
473
- * Revision 1.71  2004/05/10 11:35:11  nigelhorne
474
- * No need to update mbox.c for cli_filetype problem
475
- *
476
- * Revision 1.69  2004/05/06 11:26:49  nigelhorne
477
- * Force attachments marked as RFC822 messages to be scanned
478
- *
479
- * Revision 1.68  2004/04/29 08:59:24  nigelhorne
480
- * Tidied up SetDispositionType
481
- *
482
- * Revision 1.67  2004/04/23 10:47:41  nigelhorne
483
- * If an inline text portion has a filename treat is as an attachment
484
- *
485
- * Revision 1.66  2004/04/14 08:32:21  nigelhorne
486
- * When debugging print the email number in mailboxes
487
- *
488
- * Revision 1.65  2004/04/07 18:18:07  nigelhorne
489
- * Some occurances of W97M.Lexar were let through
490
- *
491
- * Revision 1.64  2004/04/05 09:32:20  nigelhorne
492
- * Added SCAN_TO_DISC define
493
- *
494
- * Revision 1.63  2004/04/01 15:32:34  nigelhorne
495
- * Graceful exit if messageAddLine fails in strdup
496
- *
497
- * Revision 1.62  2004/03/31 17:00:20  nigelhorne
498
- * Code tidy up free memory earlier
499
- *
500
- * Revision 1.61  2004/03/30 22:45:13  nigelhorne
501
- * Better handling of multipart/multipart messages
502
- *
503
- * Revision 1.60  2004/03/29 09:22:03  nigelhorne
504
- * Tidy up code and reduce shuffling of data
505
- *
506
- * Revision 1.59  2004/03/26 11:08:36  nigelhorne
507
- * Use cli_writen
508
- *
509
- * Revision 1.58  2004/03/25 22:40:46  nigelhorne
510
- * Removed even more calls to realloc and some duplicated code
511
- *
512
- * Revision 1.57  2004/03/21 17:19:49  nigelhorne
513
- * Handle bounce messages with no headers
514
- *
515
- * Revision 1.56  2004/03/21 09:41:26  nigelhorne
516
- * Faster scanning for non MIME messages
517
- *
518
- * Revision 1.55  2004/03/20 17:39:23  nigelhorne
519
- * First attempt to handle all bounces
520
- *
521
- * Revision 1.54  2004/03/19 15:40:45  nigelhorne
522
- * Handle empty content-disposition types
523
- *
524
- * Revision 1.53  2004/03/19 08:08:02  nigelhorne
525
- * If a message part of a multipart contains an RFC822 message that has no encoding don't scan it
526
- *
527
- * Revision 1.52  2004/03/18 21:51:41  nigelhorne
528
- * If a message only contains a single RFC822 message that has no encoding don't save for scanning
529
- *
530
- * Revision 1.51  2004/03/17 19:48:12  nigelhorne
531
- * Improved embedded RFC822 message handling
532
- *
533
- * Revision 1.50  2004/03/10 22:05:39  nigelhorne
534
- * Fix seg fault when a message in a multimessage mailbox fails to scan
535
- *
536
- * Revision 1.49  2004/03/04 13:01:58  nigelhorne
537
- * Ensure all bounces are rescanned by cl_mbox
538
- *
539
- * Revision 1.48  2004/02/27 12:16:26  nigelhorne
540
- * Catch lines just containing ':'
541
- *
542
- * Revision 1.47  2004/02/23 10:13:08  nigelhorne
543
- * Handle spaces before : in headers
544
- *
545
- * Revision 1.46  2004/02/18 13:29:19  nigelhorne
546
- * Stop buffer overflows for files with very long suffixes
547
- *
548
- * Revision 1.45  2004/02/18 10:07:40  nigelhorne
549
- * Find some Yaha
550
- *
551
- * Revision 1.44  2004/02/15 08:45:54  nigelhorne
552
- * Avoid scanning the same file twice
553
- *
554
- * Revision 1.43  2004/02/14 19:04:05  nigelhorne
555
- * Handle spaces in boundaries
556
- *
557
- * Revision 1.42  2004/02/14 17:23:45  nigelhorne
558
- * Had deleted O_BINARY by mistake
559
- *
560
- * Revision 1.41  2004/02/12 18:43:58  nigelhorne
561
- * Use mkstemp on Solaris
562
- *
563
- * Revision 1.40  2004/02/11 08:15:59  nigelhorne
564
- * Use O_BINARY for cygwin
565
- *
566
- * Revision 1.39  2004/02/06 13:46:08  kojm
567
- * Support for clamav-config.h
568
- *
569
- * Revision 1.38  2004/02/04 13:29:48  nigelhorne
570
- * Handle partial writes - and print when write fails
571
- *
572
- * Revision 1.37  2004/02/03 22:54:59  nigelhorne
573
- * Catch another example of Worm.Dumaru.Y
574
- *
575
- * Revision 1.36  2004/02/02 09:52:57  nigelhorne
576
- * Some instances of Worm.Dumaru.Y got through the net
577
- *
578
- * Revision 1.35  2004/01/28 10:15:24  nigelhorne
579
- * Added support to scan some bounce messages
580
- *
581
- * Revision 1.34  2004/01/24 17:43:37  nigelhorne
582
- * Removed (incorrect) warning about uninitialised variable
583
- *
584
- * Revision 1.33  2004/01/23 10:38:22  nigelhorne
585
- * Fixed memory leak in handling some multipart messages
586
- *
587
- * Revision 1.32  2004/01/23 08:51:19  nigelhorne
588
- * Add detection of uuencoded viruses in single part multipart/mixed files
589
- *
590
- * Revision 1.31  2004/01/22 22:13:06  nigelhorne
591
- * Prevent infinite recursion on broken uuencoded files
592
- *
593
- * Revision 1.30  2004/01/13 10:12:05  nigelhorne
594
- * Remove duplicate code when handling multipart messages
595
- *
596
- * Revision 1.29  2004/01/09 18:27:11  nigelhorne
597
- * ParseMimeHeader could corrupt arg
598
- *
599
- * Revision 1.28  2004/01/09 15:07:42  nigelhorne
600
- * Re-engineered update 1.11 lost in recent changes
601
- *
602
- * Revision 1.27  2004/01/09 14:45:59  nigelhorne
603
- * Removed duplicated code in multipart handler
604
- *
605
- * Revision 1.26  2004/01/09 10:20:54  nigelhorne
606
- * Locate uuencoded viruses hidden in text poritions of multipart/mixed mime messages
607
- *
608
- * Revision 1.25  2004/01/06 14:41:18  nigelhorne
609
- * Handle headers which do not not have a space after the ':'
610
- *
611
- * Revision 1.24  2003/12/20 13:55:36  nigelhorne
612
- * Ensure multipart just save the bodies of attachments
613
- *
614
- * Revision 1.23  2003/12/14 18:07:01  nigelhorne
615
- * Some viruses in embedded messages were not being found
616
- *
617
- * Revision 1.22  2003/12/13 16:42:23  nigelhorne
618
- * call new cli_chomp
619
- *
620
- * Revision 1.21  2003/12/11 14:35:48  nigelhorne
621
- * Better handling of encapsulated messages
622
- *
623
- * Revision 1.20  2003/12/06 04:03:26  nigelhorne
624
- * Handle hand crafted emails that incorrectly set multipart headers
625
- *
626
- * Revision 1.19  2003/11/21 07:26:31  nigelhorne
627
- * Scan multipart alternatives that have no boundaries, finds some uuencoded happy99
628
- *
629
- * Revision 1.18  2003/11/17 08:13:21  nigelhorne
630
- * Handle spaces at the end of lines of MIME headers
631
- *
632
- * Revision 1.17  2003/11/06 05:06:42  nigelhorne
633
- * Some applications weren't being scanned
634
- *
635
- * Revision 1.16  2003/11/04 08:24:00  nigelhorne
636
- * Handle multipart messages that have no text portion
637
- *
638
- * Revision 1.15  2003/10/12 20:13:49  nigelhorne
639
- * Use NO_STRTOK_R consistent with message.c
640
- *
641
- * Revision 1.14  2003/10/12 12:37:11  nigelhorne
642
- * Appledouble encoded EICAR now found
643
- *
644
- * Revision 1.13  2003/10/01 09:27:42  nigelhorne
645
- * Handle content-type header going over to a new line
646
- *
647
- * Revision 1.12  2003/09/29 17:10:19  nigelhorne
648
- * Moved stub from heap to stack since its maximum size is known
649
- *
650
- * Revision 1.11  2003/09/29 12:58:32  nigelhorne
651
- * Handle Content-Type: /; name="eicar.com"
652
- *
653
- * Revision 1.10  2003/09/28 10:06:34  nigelhorne
654
- * Compilable under SCO; removed duplicate code with message.c
655
- *
656 17
  */
657
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.222 2005/02/18 18:00:55 nigelhorne Exp $";
18
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.223 2005/03/02 20:08:24 nigelhorne Exp $";
658 19
 
659 20
 #if HAVE_CONFIG_H
660 21
 #include "clamav-config.h"
... ...
@@ -985,6 +346,10 @@ cli_mbox(const char *dir, int desc, unsigned int options)
985 985
 	int wasAlloced;
986 986
 	struct scanlist *scanlist, *scanelem;
987 987
 
988
+	if(dir == NULL) {
989
+		cli_warnmsg("cli_mbox called with NULL dir\n");
990
+		return CL_ENULLARG;
991
+	}
988 992
 	if(fstat(desc, &statb) < 0)
989 993
 		return CL_EOPEN;
990 994
 
... ...
@@ -1294,6 +659,10 @@ cli_mbox(const char *dir, int desc, unsigned int options)
1294 1294
 int
1295 1295
 cli_mbox(const char *dir, int desc, unsigned int options)
1296 1296
 {
1297
+	if(dir == NULL) {
1298
+		cli_warnmsg("cli_mbox called with NULL dir\n");
1299
+		return CL_ENULLARG;
1300
+	}
1297 1301
 	return cli_parse_mbox(dir, desc, options);
1298 1302
 }
1299 1303
 #endif
... ...
@@ -2937,8 +2306,7 @@ parseEmailBody(message *messageIn, text *textIn, const char *dir, const table_t
2937 2937
 				}
2938 2938
 			}
2939 2939
 			if(lookahead == NULL) {
2940
-				/* warning not dbg during the trial period */
2941
-				cli_warnmsg("cli_mbox: I believe it's plain text which must be clean\n");
2940
+				cli_dbgmsg("cli_mbox: I believe it's plain text which must be clean\n");
2942 2941
 				/* nothing here, move along please */
2943 2942
 				break;
2944 2943
 			}
... ...
@@ -3208,8 +2576,13 @@ boundaryStart(const char *line, const char *boundary)
3208 3208
 	 * best to avoid these false positives. For example if we have
3209 3209
 	 * boundary="1" we want to ensure that we don't break out of every line
3210 3210
 	 * that has -1 in it instead of starting --1. This needs some more work.
3211
+	 *
3212
+	 * Look with and without RFC822 comments stripped, I've seen some
3213
+	 * samples where () are taken as comments in boundaries and some where
3214
+	 * they're not. Irrespective of whatever RFC2822 says we need to find
3215
+	 * viruses in both types of mails
3211 3216
 	 */
3212
-	if(strstr(ptr, boundary) != NULL)
3217
+	if((strstr(ptr, boundary) != NULL) || (strstr(line, boundary) != NULL))
3213 3218
 		rc = 1;
3214 3219
 	else if(*ptr++ != '-')
3215 3220
 		rc = 0;
... ...
@@ -3651,13 +3024,19 @@ rfc822comments(const char *in, char *out)
3651 3651
 				backslash = 1;
3652 3652
 				break;
3653 3653
 			case '\"':
3654
+				*optr++ = '\"';
3654 3655
 				inquote = !inquote;
3655 3656
 				break;
3656 3657
 			case '(':
3657
-				commentlevel++;
3658
+				if(inquote)
3659
+					*optr++ = '(';
3660
+				else
3661
+					commentlevel++;
3658 3662
 				break;
3659 3663
 			case ')':
3660
-				if(commentlevel > 0)
3664
+				if(inquote)
3665
+					*optr++ = ')';
3666
+				else if(commentlevel > 0)
3661 3667
 					commentlevel--;
3662 3668
 				break;
3663 3669
 			default: