git-svn: trunk@1512
Nigel Horne authored on 2005/05/04 22:00:39... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Wed May 4 13:58:59 BST 2005 (njh) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav/tnef.c: If a parse fails and debugging is on, the file being |
|
4 |
+ scanned is dumped to a temporary file |
|
5 |
+ |
|
1 | 6 |
Tue May 3 02:09:08 CEST 2005 (tk) |
2 | 7 |
---------------------------------- |
3 | 8 |
* libclamav: activate PDF code (patch by NJH) |
... | ... |
@@ -24,9 +24,10 @@ |
24 | 24 |
#include "clamav-config.h" |
25 | 25 |
#endif |
26 | 26 |
|
27 |
-static char const rcsid[] = "$Id: tnef.c,v 1.14 2005/04/04 13:29:02 nigelhorne Exp $"; |
|
27 |
+static char const rcsid[] = "$Id: tnef.c,v 1.15 2005/05/04 12:57:28 nigelhorne Exp $"; |
|
28 | 28 |
|
29 | 29 |
#include <stdio.h> |
30 |
+#include <fcntl.h> |
|
30 | 31 |
|
31 | 32 |
#include "cltypes.h" |
32 | 33 |
#include "clamav.h" |
... | ... |
@@ -61,6 +62,8 @@ static int tnef_attachment(FILE *fp, const char *dir, fileblob **fbref); |
61 | 61 |
((v & 0x0000FF00) << 8) | (v << 24)) |
62 | 62 |
#endif |
63 | 63 |
|
64 |
+extern short cli_debug_flag; |
|
65 |
+ |
|
64 | 66 |
int |
65 | 67 |
cli_tnef(const char *dir, int desc) |
66 | 68 |
{ |
... | ... |
@@ -142,6 +145,34 @@ cli_tnef(const char *dir, int desc) |
142 | 142 |
break; |
143 | 143 |
default: |
144 | 144 |
cli_errmsg("TNEF - unknown level %d\n", (int)i8); |
145 |
+ |
|
146 |
+ /* |
|
147 |
+ * Dump the file incase it was part of an |
|
148 |
+ * email that's about to be deleted |
|
149 |
+ */ |
|
150 |
+ if(cli_debug_flag) { |
|
151 |
+ int fout; |
|
152 |
+ char *filename = cli_gentemp(NULL); |
|
153 |
+ char buffer[BUFSIZ]; |
|
154 |
+ |
|
155 |
+#ifdef O_BINARY |
|
156 |
+ fout = open(filename, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_BINARY, 0600); |
|
157 |
+#else |
|
158 |
+ fout = open(filename, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0600); |
|
159 |
+#endif |
|
160 |
+ |
|
161 |
+ if(fout >= 0) { |
|
162 |
+ int count; |
|
163 |
+ |
|
164 |
+ cli_warnmsg("Saving dump to %s - send to bugs@clamav.net\n", filename); |
|
165 |
+ |
|
166 |
+ lseek(desc, 0L, SEEK_SET); |
|
167 |
+ while((count = cli_readn(desc, buffer, sizeof(buffer))) >= 0) |
|
168 |
+ cli_writen(fout, buffer, count); |
|
169 |
+ close(fout); |
|
170 |
+ } |
|
171 |
+ free(filename); |
|
172 |
+ } |
|
145 | 173 |
ret = CL_EFORMAT; |
146 | 174 |
alldone = 1; |
147 | 175 |
break; |