git-svn: trunk@3506
aCaB authored on 2008/01/18 20:41:02... | ... |
@@ -1,3 +1,9 @@ |
1 |
+Fri Jan 18 12:13:16 CET 2008 (acab) |
|
2 |
+----------------------------------- |
|
3 |
+ * test: Storing the testifles byteswapped to avoid detection of the tarball. |
|
4 |
+ Real files are generated at make time and are additionally available |
|
5 |
+ under /contrib/test - close bb#398 |
|
6 |
+ |
|
1 | 7 |
Thu Jan 17 21:38:58 CET 2008 (acab) |
2 | 8 |
----------------------------------- |
3 | 9 |
* libclamav/nsis: use mmap if avail, prevent cli_malloc() spam if unavail, |
... | ... |
@@ -16,8 +16,8 @@ |
16 | 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
17 | 17 |
# MA 02110-1301, USA. |
18 | 18 |
|
19 |
-SUBDIRS = libclamunrar libclamunrar_iface libclamav clamscan clamd clamdscan freshclam sigtool clamconf database docs etc clamav-milter |
|
20 |
-EXTRA_DIST = FAQ contrib test examples BUGS shared libclamav.pc.in UPGRADE COPYING.bzip2 COPYING.lzma COPYING.unrar COPYING.LGPL COPYING.file |
|
19 |
+SUBDIRS = libclamunrar libclamunrar_iface libclamav clamscan clamd clamdscan freshclam sigtool clamconf database docs etc clamav-milter test |
|
20 |
+EXTRA_DIST = FAQ examples BUGS shared libclamav.pc.in UPGRADE COPYING.bzip2 COPYING.lzma COPYING.unrar COPYING.LGPL COPYING.file |
|
21 | 21 |
|
22 | 22 |
bin_SCRIPTS=clamav-config |
23 | 23 |
|
... | ... |
@@ -235,8 +235,8 @@ target_os = @target_os@ |
235 | 235 |
target_vendor = @target_vendor@ |
236 | 236 |
top_builddir = @top_builddir@ |
237 | 237 |
top_srcdir = @top_srcdir@ |
238 |
-SUBDIRS = libclamunrar libclamunrar_iface libclamav clamscan clamd clamdscan freshclam sigtool clamconf database docs etc clamav-milter |
|
239 |
-EXTRA_DIST = FAQ contrib test examples BUGS shared libclamav.pc.in UPGRADE COPYING.bzip2 COPYING.lzma COPYING.unrar COPYING.LGPL COPYING.file |
|
238 |
+SUBDIRS = libclamunrar libclamunrar_iface libclamav clamscan clamd clamdscan freshclam sigtool clamconf database docs etc clamav-milter test |
|
239 |
+EXTRA_DIST = FAQ examples BUGS shared libclamav.pc.in UPGRADE COPYING.bzip2 COPYING.lzma COPYING.unrar COPYING.LGPL COPYING.file |
|
240 | 240 |
bin_SCRIPTS = clamav-config |
241 | 241 |
pkgconfigdir = $(libdir)/pkgconfig |
242 | 242 |
pkgconfig_DATA = libclamav.pc |
... | ... |
@@ -16788,7 +16788,7 @@ echo "$as_me: WARNING: Unable to determine FPU endianess, some features may not |
16788 | 16788 |
esac |
16789 | 16789 |
|
16790 | 16790 |
|
16791 |
-ac_config_files="$ac_config_files libclamunrar/Makefile libclamunrar_iface/Makefile libclamav/Makefile libclamav/lzma/Makefile clamscan/Makefile database/Makefile docs/Makefile clamd/Makefile clamdscan/Makefile clamav-milter/Makefile freshclam/Makefile sigtool/Makefile clamconf/Makefile etc/Makefile Makefile clamav-config libclamav.pc docs/man/clamav-milter.8 docs/man/clamconf.1 docs/man/clamd.8 docs/man/clamd.conf.5 docs/man/clamdscan.1 docs/man/clamscan.1 docs/man/freshclam.1 docs/man/freshclam.conf.5 docs/man/sigtool.1" |
|
16791 |
+ac_config_files="$ac_config_files libclamunrar/Makefile libclamunrar_iface/Makefile libclamav/Makefile libclamav/lzma/Makefile clamscan/Makefile database/Makefile docs/Makefile clamd/Makefile clamdscan/Makefile clamav-milter/Makefile freshclam/Makefile sigtool/Makefile clamconf/Makefile etc/Makefile test/Makefile Makefile clamav-config libclamav.pc docs/man/clamav-milter.8 docs/man/clamconf.1 docs/man/clamd.8 docs/man/clamd.conf.5 docs/man/clamdscan.1 docs/man/clamscan.1 docs/man/freshclam.1 docs/man/freshclam.conf.5 docs/man/sigtool.1" |
|
16792 | 16792 |
|
16793 | 16793 |
cat >confcache <<\_ACEOF |
16794 | 16794 |
# This file is a shell script that caches the results of configure |
... | ... |
@@ -17418,6 +17418,7 @@ do |
17418 | 17418 |
"sigtool/Makefile") CONFIG_FILES="$CONFIG_FILES sigtool/Makefile" ;; |
17419 | 17419 |
"clamconf/Makefile") CONFIG_FILES="$CONFIG_FILES clamconf/Makefile" ;; |
17420 | 17420 |
"etc/Makefile") CONFIG_FILES="$CONFIG_FILES etc/Makefile" ;; |
17421 |
+ "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;; |
|
17421 | 17422 |
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; |
17422 | 17423 |
"clamav-config") CONFIG_FILES="$CONFIG_FILES clamav-config" ;; |
17423 | 17424 |
"libclamav.pc") CONFIG_FILES="$CONFIG_FILES libclamav.pc" ;; |
12 | 15 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,374 @@ |
0 |
+/* |
|
1 |
+ * Copyright (C) 2007 Nigel Horne <njh@bandsman.co.uk> |
|
2 |
+ * |
|
3 |
+ * This program is free software; you can redistribute it and/or modify |
|
4 |
+ * it under the terms of the GNU General Public License as published by |
|
5 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
6 |
+ * (at your option) any later version. |
|
7 |
+ * |
|
8 |
+ * This program is distributed in the hope that it will be useful, |
|
9 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 |
+ * GNU General Public License for more details. |
|
12 |
+ * |
|
13 |
+ * You should have received a copy of the GNU General Public License |
|
14 |
+ * along with this program; if not, write to the Free Software |
|
15 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
16 |
+ * MA 02110-1301, USA. |
|
17 |
+ * |
|
18 |
+ * Compare the results of scanning files on a set of machines |
|
19 |
+ * This is useful for regression testing versions, and for testing |
|
20 |
+ * across different operating systems and architectures |
|
21 |
+ * The file is always copied which is slow, and could be removed for regression |
|
22 |
+ * testing, if we have some mechanism to sync the data |
|
23 |
+ */ |
|
24 |
+ |
|
25 |
+#include <stdio.h> |
|
26 |
+#include <stdlib.h> |
|
27 |
+#include <sys/types.h> |
|
28 |
+#include <dirent.h> |
|
29 |
+#include <sys/socket.h> |
|
30 |
+#include <netinet/in.h> |
|
31 |
+#include <arpa/inet.h> |
|
32 |
+#include <netdb.h> |
|
33 |
+#include <memory.h> |
|
34 |
+#include <unistd.h> |
|
35 |
+#include <pthread.h> |
|
36 |
+#include <string.h> |
|
37 |
+#include <signal.h> |
|
38 |
+ |
|
39 |
+#define PORT 3310 |
|
40 |
+#define LEN 128 |
|
41 |
+ |
|
42 |
+/* |
|
43 |
+ * Ensure you don't have StreamMaxLength on any of the servers, or that it's |
|
44 |
+ * big enough for all your samples |
|
45 |
+ * Uses SESSIONS, which isn't good |
|
46 |
+ * If localhost is one of them, it's probably best to put it last so that it |
|
47 |
+ * can be scanning while waiting for the remote machines to respond |
|
48 |
+ */ |
|
49 |
+static struct machine { |
|
50 |
+ const char *name; |
|
51 |
+ in_addr_t ip; |
|
52 |
+ int sock; |
|
53 |
+} machines[] = { |
|
54 |
+ { "eric", 0, -1 }, |
|
55 |
+ /*{ "motorola", 0, -1 },*/ |
|
56 |
+ /*{ "ultra60", 0, -1 },*/ |
|
57 |
+ { "mac", 0, -1 }, |
|
58 |
+ { "localhost", 0, -1 }, |
|
59 |
+ { NULL, 0, -1 } |
|
60 |
+}; |
|
61 |
+ |
|
62 |
+struct args { |
|
63 |
+ const char *filename; |
|
64 |
+ const struct machine *m; |
|
65 |
+ char *ret; |
|
66 |
+}; |
|
67 |
+ |
|
68 |
+static void dir(const char *dirname); |
|
69 |
+static in_addr_t resolve(const char *machine); |
|
70 |
+static int start(in_addr_t ip); |
|
71 |
+static void *scan(void *v); |
|
72 |
+ |
|
73 |
+int |
|
74 |
+main(int argc, char **argv) |
|
75 |
+{ |
|
76 |
+ struct machine *m; |
|
77 |
+ |
|
78 |
+ if(argc <= 1) { |
|
79 |
+ fputs("Arg count\n", stderr); |
|
80 |
+ return 1; |
|
81 |
+ } |
|
82 |
+ |
|
83 |
+ for(m = machines; m->name; m++) { |
|
84 |
+ m->ip = resolve(m->name); |
|
85 |
+ |
|
86 |
+ if(m->ip == INADDR_NONE) { |
|
87 |
+ fprintf(stderr, "Can't resolve %s\n", m->name); |
|
88 |
+ return 1; |
|
89 |
+ } |
|
90 |
+ m->sock = start(m->ip); |
|
91 |
+ if(m->sock < 0) |
|
92 |
+ fprintf(stderr, "%s is down\n", m->name); |
|
93 |
+ } |
|
94 |
+ |
|
95 |
+ signal(SIGPIPE, SIG_IGN); |
|
96 |
+ |
|
97 |
+ while(*++argv) |
|
98 |
+ dir(*argv); |
|
99 |
+ |
|
100 |
+ return 0; |
|
101 |
+} |
|
102 |
+ |
|
103 |
+static void |
|
104 |
+dir(const char *dirname) |
|
105 |
+{ |
|
106 |
+ int i, nmachines; |
|
107 |
+ const struct dirent *dirent; |
|
108 |
+ struct machine *m; |
|
109 |
+ DIR *d = opendir(dirname); |
|
110 |
+ char **results; |
|
111 |
+ |
|
112 |
+ if(d == NULL) { |
|
113 |
+ perror(dirname); |
|
114 |
+ return; |
|
115 |
+ } |
|
116 |
+ for(nmachines = 0, m = machines; m->name; m++) |
|
117 |
+ if(m->sock >= 0) |
|
118 |
+ nmachines++; |
|
119 |
+ |
|
120 |
+ if(nmachines < 2) { |
|
121 |
+ fputs("Needs at least 2 machines up to run\n", stderr); |
|
122 |
+ closedir(d); |
|
123 |
+ return; |
|
124 |
+ } |
|
125 |
+ |
|
126 |
+ results = (char **)malloc(nmachines * sizeof(char *)); |
|
127 |
+ if(results == NULL) |
|
128 |
+ return; |
|
129 |
+ for(i = 0, m = machines; m->name; m++) |
|
130 |
+ if(m->sock >= 0) { |
|
131 |
+ results[i] = malloc(LEN); |
|
132 |
+ if(results[i++] == NULL) { |
|
133 |
+ free(results); |
|
134 |
+ closedir(d); |
|
135 |
+ return; |
|
136 |
+ } |
|
137 |
+ } |
|
138 |
+ |
|
139 |
+ if(i != nmachines) { |
|
140 |
+ fputs("Failed sanity check\n", stderr); |
|
141 |
+ closedir(d); |
|
142 |
+ return; |
|
143 |
+ } |
|
144 |
+ |
|
145 |
+ while((dirent = readdir(d)) != NULL) { |
|
146 |
+ int nthreads, founddiffs; |
|
147 |
+ pthread_t *tids; |
|
148 |
+ struct args *args; |
|
149 |
+ char name[PATH_MAX]; |
|
150 |
+ |
|
151 |
+ if(dirent->d_ino == (ino_t)0) |
|
152 |
+ continue; |
|
153 |
+ if(dirent->d_name[0] == '.') |
|
154 |
+ continue; |
|
155 |
+ |
|
156 |
+ tids = malloc(nmachines * sizeof(pthread_t)); |
|
157 |
+ if(tids == NULL) { |
|
158 |
+ free(results); |
|
159 |
+ closedir(d); |
|
160 |
+ return; |
|
161 |
+ } |
|
162 |
+ args = malloc(nmachines * sizeof(struct args)); |
|
163 |
+ if(args == NULL) { |
|
164 |
+ free(tids); |
|
165 |
+ free(results); |
|
166 |
+ closedir(d); |
|
167 |
+ return; |
|
168 |
+ } |
|
169 |
+ |
|
170 |
+ snprintf(name, sizeof(name) -1, "%s/%s", dirname, dirent->d_name); |
|
171 |
+ for(nthreads = 0, m = machines; m->name; m++) { |
|
172 |
+ if(m->sock < 0) |
|
173 |
+ continue; |
|
174 |
+ |
|
175 |
+ args[nthreads].filename = name; |
|
176 |
+ args[nthreads].m = m; |
|
177 |
+ args[nthreads].ret = results[nthreads]; |
|
178 |
+ pthread_create(&tids[nthreads], NULL, scan, &args[nthreads]); |
|
179 |
+ nthreads++; |
|
180 |
+ } |
|
181 |
+ /*printf("Scanning %s\n", name);*/ |
|
182 |
+ founddiffs = 0; |
|
183 |
+ while(--nthreads >= 0) |
|
184 |
+ /* TODO: timeout */ |
|
185 |
+ pthread_join(tids[nthreads], NULL); |
|
186 |
+ |
|
187 |
+ free(args); |
|
188 |
+ free(tids); |
|
189 |
+ for(i = 0; i <= nmachines - 2; i++) { |
|
190 |
+ int j; |
|
191 |
+ |
|
192 |
+ for(j = i + 1; j <= nmachines - 1; j++) { |
|
193 |
+ const char *s, *t; |
|
194 |
+ |
|
195 |
+ s = strchr(results[i], ' '); |
|
196 |
+ t = strchr(results[j], ' '); |
|
197 |
+ if((s == NULL) || (t == NULL) || (strcmp(s, t) != 0)) { |
|
198 |
+ printf("%s:\n", name); |
|
199 |
+ printf("\t%s: %s\n", machines[i].name, s ? s : "null"); |
|
200 |
+ printf("\t%s: %s\n", machines[j].name, t ? t : "null"); |
|
201 |
+ founddiffs = 1; |
|
202 |
+ } |
|
203 |
+ } |
|
204 |
+ } |
|
205 |
+ |
|
206 |
+ /*if(!founddiffs) |
|
207 |
+ printf("%s passed\n", name);*/ |
|
208 |
+ } |
|
209 |
+ closedir(d); |
|
210 |
+} |
|
211 |
+ |
|
212 |
+static in_addr_t |
|
213 |
+resolve(const char *machine) |
|
214 |
+{ |
|
215 |
+ in_addr_t ret = inet_addr(machine); |
|
216 |
+ |
|
217 |
+ if(ret == INADDR_NONE) { |
|
218 |
+ const struct hostent *h = gethostbyname(machine); |
|
219 |
+ |
|
220 |
+ if(h == NULL) { |
|
221 |
+ fprintf(stderr, "Unknown host %s\n", machine); |
|
222 |
+ return INADDR_NONE; |
|
223 |
+ } |
|
224 |
+ |
|
225 |
+ memcpy((char *)&ret, h->h_addr, sizeof(in_addr_t)); |
|
226 |
+ } |
|
227 |
+ return ret; |
|
228 |
+} |
|
229 |
+ |
|
230 |
+static int |
|
231 |
+start(in_addr_t ip) |
|
232 |
+{ |
|
233 |
+ int sock; |
|
234 |
+ const struct protoent *proto; |
|
235 |
+ struct sockaddr_in server; |
|
236 |
+ |
|
237 |
+ memset((char *)&server, 0, sizeof(struct sockaddr_in)); |
|
238 |
+ server.sin_family = AF_INET; |
|
239 |
+ server.sin_port = (in_port_t)htons(PORT); |
|
240 |
+ server.sin_addr.s_addr = ip; |
|
241 |
+ |
|
242 |
+ proto = getprotobyname("tcp"); |
|
243 |
+ if(proto == NULL) { |
|
244 |
+ fputs("Unknown prototol tcp, check /etc/protocols\n", stderr); |
|
245 |
+ return -1; |
|
246 |
+ } else if((sock = socket(AF_INET, SOCK_STREAM, proto->p_proto)) < 0) { |
|
247 |
+ perror("socket"); |
|
248 |
+ return -1; |
|
249 |
+ } else if(connect(sock, (struct sockaddr *)&server, sizeof(struct sockaddr_in)) < 0) { |
|
250 |
+ perror("connect"); |
|
251 |
+ close(sock); |
|
252 |
+ return -1; |
|
253 |
+ } else if(send(sock, "SESSION\n", 8, 0) < 8) { |
|
254 |
+ perror("send"); |
|
255 |
+ close(sock); |
|
256 |
+ return -1; |
|
257 |
+ } |
|
258 |
+ return sock; |
|
259 |
+} |
|
260 |
+ |
|
261 |
+static void * |
|
262 |
+scan(void *v) |
|
263 |
+{ |
|
264 |
+ struct args *args; |
|
265 |
+ FILE *fin; |
|
266 |
+ int sock; |
|
267 |
+ ssize_t nbytes; |
|
268 |
+ size_t buflen; |
|
269 |
+ in_port_t port; |
|
270 |
+ struct sockaddr_in data; |
|
271 |
+ const struct machine *m; |
|
272 |
+ char buf[1024]; /* must be less than MTU */ |
|
273 |
+ |
|
274 |
+ args = (struct args *)v; |
|
275 |
+ m = args->m; |
|
276 |
+ if(m->sock < 0) |
|
277 |
+ return NULL; |
|
278 |
+ if(m->ip == htonl(INADDR_LOOPBACK)) { |
|
279 |
+ char cmd[NAME_MAX + 7]; |
|
280 |
+ |
|
281 |
+ snprintf(cmd, sizeof(cmd) - 1, "SCAN %s\n", args->filename); |
|
282 |
+ buflen = strlen(cmd); |
|
283 |
+ |
|
284 |
+ if(send(m->sock, cmd, buflen, 0) != (ssize_t)buflen) { |
|
285 |
+ perror(m->name); |
|
286 |
+ return NULL; |
|
287 |
+ } |
|
288 |
+ nbytes = recv(m->sock, args->ret, LEN, 0); |
|
289 |
+ if(nbytes < 0) { |
|
290 |
+ perror(m->name); |
|
291 |
+ return NULL; |
|
292 |
+ } |
|
293 |
+ args->ret[nbytes - 1] = '\0'; /* remove the trailing \n */ |
|
294 |
+ |
|
295 |
+ return NULL; |
|
296 |
+ } |
|
297 |
+ fin = fopen(args->filename, "r"); |
|
298 |
+ if(fin == NULL) { |
|
299 |
+ perror(args->filename); |
|
300 |
+ return NULL; |
|
301 |
+ } |
|
302 |
+ if(send(m->sock, "STREAM\n", 7, 0) != 7) { |
|
303 |
+ perror(m->name); |
|
304 |
+ fclose(fin); |
|
305 |
+ return NULL; |
|
306 |
+ } |
|
307 |
+ |
|
308 |
+ if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { |
|
309 |
+ perror("socket"); |
|
310 |
+ fputs("Failed to create TCPSocket to talk to clamd\n", stderr); |
|
311 |
+ fclose(fin); |
|
312 |
+ return NULL; |
|
313 |
+ } |
|
314 |
+ |
|
315 |
+ nbytes = recv(m->sock, buf, sizeof(buf), 0); |
|
316 |
+ if(nbytes <= 0) { |
|
317 |
+ perror(m->name); |
|
318 |
+ close(sock); |
|
319 |
+ fclose(fin); |
|
320 |
+ return NULL; |
|
321 |
+ } |
|
322 |
+ buf[nbytes] = '\0'; |
|
323 |
+ |
|
324 |
+ if(sscanf(buf, "PORT %hu\n", &port) != 1) { |
|
325 |
+ fprintf(stderr, "Expected port information from clamd, got '%s'", |
|
326 |
+ buf); |
|
327 |
+ close(sock); |
|
328 |
+ fclose(fin); |
|
329 |
+ return NULL; |
|
330 |
+ } |
|
331 |
+ |
|
332 |
+ memset((char *)&data, 0, sizeof(struct sockaddr_in)); |
|
333 |
+ data.sin_family = AF_INET; |
|
334 |
+ data.sin_port = (in_port_t)htons(port); |
|
335 |
+ data.sin_addr.s_addr = m->ip; |
|
336 |
+ |
|
337 |
+ if(connect(sock, (struct sockaddr *)&data, sizeof(struct sockaddr_in)) < 0) { |
|
338 |
+ perror(m->name); |
|
339 |
+ fprintf(stderr, "Couldn't connect to port %d\n", port); |
|
340 |
+ close(sock); |
|
341 |
+ fclose(fin); |
|
342 |
+ return NULL; |
|
343 |
+ } |
|
344 |
+ |
|
345 |
+ shutdown(sock, SHUT_RD); |
|
346 |
+ |
|
347 |
+ while((buflen = fread(buf, 1, sizeof(buf), fin)) > 0) { |
|
348 |
+ ssize_t sent = send(sock, buf, buflen, 0); |
|
349 |
+ |
|
350 |
+ if(sent != (ssize_t)buflen) { |
|
351 |
+ /* Probably hit scanstream len */ |
|
352 |
+ if(sent < 0) |
|
353 |
+ perror(m->name); |
|
354 |
+ else |
|
355 |
+ fprintf(stderr, "%s: only sent %d bytes of %d to %s\n", |
|
356 |
+ args->filename, sent, buflen, m->name); |
|
357 |
+ break; |
|
358 |
+ } |
|
359 |
+ } |
|
360 |
+ |
|
361 |
+ close(sock); |
|
362 |
+ fclose(fin); |
|
363 |
+ |
|
364 |
+ /* TODO: timeout */ |
|
365 |
+ nbytes = recv(m->sock, args->ret, LEN, 0); |
|
366 |
+ if(nbytes < 0) { |
|
367 |
+ perror(m->name); |
|
368 |
+ return NULL; |
|
369 |
+ } |
|
370 |
+ args->ret[(nbytes) ? (nbytes - 1) : 0] = '\0'; /* remove the trailing \n */ |
|
371 |
+ |
|
372 |
+ return NULL; |
|
373 |
+} |
0 | 374 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,313 @@ |
0 |
+/* |
|
1 |
+ * Copyright (C) 2006 Nigel Horne <njh@bandsman.co.uk> |
|
2 |
+ * |
|
3 |
+ * This program is free software; you can redistribute it and/or modify |
|
4 |
+ * it under the terms of the GNU General Public License as published by |
|
5 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
6 |
+ * (at your option) any later version. |
|
7 |
+ * |
|
8 |
+ * This program is distributed in the hope that it will be useful, |
|
9 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 |
+ * GNU General Public License for more details. |
|
12 |
+ * |
|
13 |
+ * You should have received a copy of the GNU General Public License |
|
14 |
+ * along with this program; if not, write to the Free Software |
|
15 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
16 |
+ * MA 02110-1301, USA. |
|
17 |
+ * |
|
18 |
+ * $CC $CFLAGS -I../.. -I../../libclamav debugm.c -lclamav |
|
19 |
+ * Now try a.out /sbin/* or a.out /usr/bin/* |
|
20 |
+ * |
|
21 |
+ * njh@bandsman.co.uk |
|
22 |
+ */ |
|
23 |
+#include <stdio.h> |
|
24 |
+#include <errno.h> |
|
25 |
+#include <sys/stat.h> |
|
26 |
+#include <sys/types.h> |
|
27 |
+#include <fcntl.h> |
|
28 |
+#include <malloc.h> |
|
29 |
+#include <clamav.h> |
|
30 |
+#include <sys/resource.h> |
|
31 |
+#include <features.h> |
|
32 |
+#include <unistd.h> |
|
33 |
+#include <memory.h> |
|
34 |
+#include <pthread.h> |
|
35 |
+#include "clamav-config.h" |
|
36 |
+#include "others.h" |
|
37 |
+#include "mbox.h" |
|
38 |
+#include "pdf.h" |
|
39 |
+#include "binhex.h" |
|
40 |
+#include "untar.h" |
|
41 |
+#include "special.h" |
|
42 |
+#include "tnef.h" |
|
43 |
+#include "pst.h" |
|
44 |
+#include "pe.h" |
|
45 |
+ |
|
46 |
+struct args { |
|
47 |
+ cli_ctx ctx; |
|
48 |
+ const char *filename; |
|
49 |
+}; |
|
50 |
+ |
|
51 |
+static void * |
|
52 |
+mbox(void *v) |
|
53 |
+{ |
|
54 |
+ struct args *args = (struct args *)v; |
|
55 |
+ int fd = open(args->filename, O_RDONLY); |
|
56 |
+ |
|
57 |
+ if(fd < 0) { |
|
58 |
+ perror(args->filename); |
|
59 |
+ return NULL; |
|
60 |
+ } |
|
61 |
+ printf("cl_mbox(%s) returns %d\n", |
|
62 |
+ args->filename, cli_mbox("/tmp/libclamav", fd, &args->ctx)); |
|
63 |
+ close(fd); |
|
64 |
+ |
|
65 |
+ return NULL; |
|
66 |
+} |
|
67 |
+ |
|
68 |
+static void * |
|
69 |
+pdf(void *v) |
|
70 |
+{ |
|
71 |
+ struct args *args = (struct args *)v; |
|
72 |
+ int fd = open(args->filename, O_RDONLY); |
|
73 |
+ |
|
74 |
+ if(fd < 0) { |
|
75 |
+ perror(args->filename); |
|
76 |
+ return NULL; |
|
77 |
+ } |
|
78 |
+ printf("cl_pdf(%s) returns %d\n", |
|
79 |
+ args->filename, cli_pdf("/tmp/libclamav", fd, &args->ctx)); |
|
80 |
+ close(fd); |
|
81 |
+ |
|
82 |
+ return NULL; |
|
83 |
+} |
|
84 |
+ |
|
85 |
+static void * |
|
86 |
+scandir(void *v) |
|
87 |
+{ |
|
88 |
+ struct args *args = (struct args *)v; |
|
89 |
+ int fd = open(args->filename, O_RDONLY); |
|
90 |
+ |
|
91 |
+ if(fd < 0) { |
|
92 |
+ perror(args->filename); |
|
93 |
+ return NULL; |
|
94 |
+ } |
|
95 |
+ printf("cl_scandir(%s) returns %d\n", |
|
96 |
+ args->filename, cli_scandir("/tmp/libclamav", &args->ctx)); |
|
97 |
+ close(fd); |
|
98 |
+ |
|
99 |
+ return NULL; |
|
100 |
+} |
|
101 |
+ |
|
102 |
+static void * |
|
103 |
+untar(void *v) |
|
104 |
+{ |
|
105 |
+ struct args *args = (struct args *)v; |
|
106 |
+ int fd = open(args->filename, O_RDONLY); |
|
107 |
+ |
|
108 |
+ if(fd < 0) { |
|
109 |
+ perror(args->filename); |
|
110 |
+ return NULL; |
|
111 |
+ } |
|
112 |
+ printf("cl_untar(%s) returns %d\n", |
|
113 |
+ args->filename, cli_untar("/tmp/libclamav", fd, 1)); |
|
114 |
+ close(fd); |
|
115 |
+ |
|
116 |
+ return NULL; |
|
117 |
+} |
|
118 |
+ |
|
119 |
+static void * |
|
120 |
+binhex(void *v) |
|
121 |
+{ |
|
122 |
+ struct args *args = (struct args *)v; |
|
123 |
+ int fd = open(args->filename, O_RDONLY); |
|
124 |
+ |
|
125 |
+ if(fd < 0) { |
|
126 |
+ perror(args->filename); |
|
127 |
+ return NULL; |
|
128 |
+ } |
|
129 |
+ printf("cl_binhex(%s) returns %d\n", |
|
130 |
+ args->filename, cli_binhex("/tmp/libclamav", fd)); |
|
131 |
+ close(fd); |
|
132 |
+ |
|
133 |
+ return NULL; |
|
134 |
+} |
|
135 |
+ |
|
136 |
+static void * |
|
137 |
+jpeg(void *v) |
|
138 |
+{ |
|
139 |
+ struct args *args = (struct args *)v; |
|
140 |
+ int fd = open(args->filename, O_RDONLY); |
|
141 |
+ |
|
142 |
+ if(fd < 0) { |
|
143 |
+ perror(args->filename); |
|
144 |
+ return NULL; |
|
145 |
+ } |
|
146 |
+ printf("cli_check_jpeg_exploit(%s) returns %d\n", |
|
147 |
+ args->filename, cli_check_jpeg_exploit(fd)); |
|
148 |
+ close(fd); |
|
149 |
+ |
|
150 |
+ return NULL; |
|
151 |
+} |
|
152 |
+ |
|
153 |
+static void * |
|
154 |
+tnef(void *v) |
|
155 |
+{ |
|
156 |
+ struct args *args = (struct args *)v; |
|
157 |
+ int fd = open(args->filename, O_RDONLY); |
|
158 |
+ |
|
159 |
+ if(fd < 0) { |
|
160 |
+ perror(args->filename); |
|
161 |
+ return NULL; |
|
162 |
+ } |
|
163 |
+ printf("cli_tnef(%s) returns %d\n", |
|
164 |
+ args->filename, cli_tnef("/tmp/libclamav", fd)); |
|
165 |
+ close(fd); |
|
166 |
+ |
|
167 |
+ return NULL; |
|
168 |
+} |
|
169 |
+ |
|
170 |
+static void * |
|
171 |
+uuencode(void *v) |
|
172 |
+{ |
|
173 |
+ struct args *args = (struct args *)v; |
|
174 |
+ int fd = open(args->filename, O_RDONLY); |
|
175 |
+ |
|
176 |
+ if(fd < 0) { |
|
177 |
+ perror(args->filename); |
|
178 |
+ return NULL; |
|
179 |
+ } |
|
180 |
+ printf("cli_uuencode(%s) returns %d\n", |
|
181 |
+ args->filename, cli_uuencode("/tmp/libclamav", fd)); |
|
182 |
+ close(fd); |
|
183 |
+ |
|
184 |
+ return NULL; |
|
185 |
+} |
|
186 |
+ |
|
187 |
+static void * |
|
188 |
+pst(void *v) |
|
189 |
+{ |
|
190 |
+ struct args *args = (struct args *)v; |
|
191 |
+ int fd = open(args->filename, O_RDONLY); |
|
192 |
+ |
|
193 |
+ if(fd < 0) { |
|
194 |
+ perror(args->filename); |
|
195 |
+ return NULL; |
|
196 |
+ } |
|
197 |
+ printf("cli_pst(%s) returns %d\n", |
|
198 |
+ args->filename, cli_pst("/tmp/libclamav", fd)); |
|
199 |
+ close(fd); |
|
200 |
+ |
|
201 |
+ return NULL; |
|
202 |
+} |
|
203 |
+ |
|
204 |
+static void * |
|
205 |
+pe(void *v) |
|
206 |
+{ |
|
207 |
+ struct args *args = (struct args *)v; |
|
208 |
+ int fd = open(args->filename, O_RDONLY); |
|
209 |
+ |
|
210 |
+ if(fd < 0) { |
|
211 |
+ perror(args->filename); |
|
212 |
+ return NULL; |
|
213 |
+ } |
|
214 |
+ printf("cli_scanpe(%s) returns %d\n", |
|
215 |
+ args->filename, cli_scanpe(fd, &args->ctx)); |
|
216 |
+ close(fd); |
|
217 |
+ |
|
218 |
+ return NULL; |
|
219 |
+} |
|
220 |
+ |
|
221 |
+int |
|
222 |
+main(int argc, char **argv) |
|
223 |
+{ |
|
224 |
+ struct rlimit rlim; |
|
225 |
+ const char *virname; |
|
226 |
+ struct cl_engine engine; |
|
227 |
+ struct cl_limits limits; |
|
228 |
+ unsigned long scanned; |
|
229 |
+ struct args args; |
|
230 |
+ |
|
231 |
+ if(argc == 1) { |
|
232 |
+ fprintf(stderr, "Usage: %s files...\n", argv[0]); |
|
233 |
+ return 1; |
|
234 |
+ } |
|
235 |
+ rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY; |
|
236 |
+ if(setrlimit(RLIMIT_CORE, &rlim) < 0) |
|
237 |
+ perror("setrlimit"); |
|
238 |
+ |
|
239 |
+ if((mkdir("/tmp/libclamav", 0750) < 0) && (errno != EEXIST)) { |
|
240 |
+ perror("/tmp/libclamav"); |
|
241 |
+ return errno; |
|
242 |
+ } |
|
243 |
+ |
|
244 |
+ memset(&args.ctx, '\0', sizeof(cli_ctx)); |
|
245 |
+ args.ctx.engine = &engine; |
|
246 |
+ args.ctx.virname = &virname; |
|
247 |
+ args.ctx.limits = &limits; |
|
248 |
+ args.ctx.scanned = &scanned; |
|
249 |
+ args.ctx.options = 0; |
|
250 |
+ |
|
251 |
+ while(*++argv) { |
|
252 |
+ pthread_t t; |
|
253 |
+ |
|
254 |
+ args.filename = *argv; |
|
255 |
+ |
|
256 |
+ if(pthread_create(&t, NULL, mbox, &args) != 0) |
|
257 |
+ perror("pthread_create"); |
|
258 |
+ if(pthread_detach(t) != 0) |
|
259 |
+ perror("pthread_detach"); |
|
260 |
+ |
|
261 |
+ if(pthread_create(&t, NULL, pdf, &args) != 0) |
|
262 |
+ perror("pthread_create"); |
|
263 |
+ if(pthread_detach(t) != 0) |
|
264 |
+ perror("pthread_detach"); |
|
265 |
+ |
|
266 |
+ if(pthread_create(&t, NULL, untar, &args) != 0) |
|
267 |
+ perror("pthread_create"); |
|
268 |
+ if(pthread_detach(t) != 0) |
|
269 |
+ perror("pthread_detach"); |
|
270 |
+ |
|
271 |
+ if(pthread_create(&t, NULL, binhex, &args) != 0) |
|
272 |
+ perror("pthread_create"); |
|
273 |
+ if(pthread_detach(t) != 0) |
|
274 |
+ perror("pthread_detach"); |
|
275 |
+ |
|
276 |
+ if(pthread_create(&t, NULL, jpeg, &args) != 0) |
|
277 |
+ perror("pthread_create"); |
|
278 |
+ if(pthread_detach(t) != 0) |
|
279 |
+ perror("pthread_detach"); |
|
280 |
+ |
|
281 |
+ if(pthread_create(&t, NULL, tnef, &args) != 0) |
|
282 |
+ perror("pthread_create"); |
|
283 |
+ if(pthread_detach(t) != 0) |
|
284 |
+ perror("pthread_detach"); |
|
285 |
+ |
|
286 |
+ if(pthread_create(&t, NULL, uuencode, &args) != 0) |
|
287 |
+ perror("pthread_create"); |
|
288 |
+ if(pthread_detach(t) != 0) |
|
289 |
+ perror("pthread_detach"); |
|
290 |
+ |
|
291 |
+ if(pthread_create(&t, NULL, pst, &args) != 0) |
|
292 |
+ perror("pthread_create"); |
|
293 |
+ if(pthread_detach(t) != 0) |
|
294 |
+ perror("pthread_detach"); |
|
295 |
+ |
|
296 |
+ if(pthread_create(&t, NULL, pe, &args) != 0) |
|
297 |
+ perror("pthread_create"); |
|
298 |
+ if(pthread_detach(t) != 0) |
|
299 |
+ perror("pthread_detach"); |
|
300 |
+ |
|
301 |
+ /* TODO: pass through all in cli_magic_scandesc */ |
|
302 |
+ if(pthread_create(&t, NULL, scandir, &args) != 0) |
|
303 |
+ perror("pthread_create"); |
|
304 |
+ if(pthread_detach(t) != 0) |
|
305 |
+ perror("pthread_detach"); |
|
306 |
+ } |
|
307 |
+ puts("Hit SIGINT when all is finished"); |
|
308 |
+ pause(); |
|
309 |
+ puts("Finished - don't forget to rm -rf /tmp/libclamav"); |
|
310 |
+ |
|
311 |
+ return 0; |
|
312 |
+} |
0 | 313 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,91 @@ |
0 |
+/* |
|
1 |
+ * $CC $CFLAGS -I../.. debugm.c -lclamav -lefence (or what ever memory debugger) |
|
2 |
+ * If you're going to use HAVE_BACKTRACE, ensure CFLAGS includes -g and doesn't |
|
3 |
+ * include -fomit-frame-pointer |
|
4 |
+ * |
|
5 |
+ * njh@bandsman.co.uk |
|
6 |
+ */ |
|
7 |
+#include <stdio.h> |
|
8 |
+#include <errno.h> |
|
9 |
+#include <sys/stat.h> |
|
10 |
+#include <sys/types.h> |
|
11 |
+#include <fcntl.h> |
|
12 |
+#include <malloc.h> |
|
13 |
+#include <clamav.h> |
|
14 |
+#include <sys/resource.h> |
|
15 |
+#include <signal.h> |
|
16 |
+#include <features.h> |
|
17 |
+#include "clamav-config.h" |
|
18 |
+ |
|
19 |
+#if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 |
|
20 |
+/*#define HAVE_BACKTRACE /* Only tested on Linux... */ |
|
21 |
+#endif |
|
22 |
+ |
|
23 |
+#ifdef HAVE_BACKTRACE |
|
24 |
+#include <execinfo.h> |
|
25 |
+#endif |
|
26 |
+ |
|
27 |
+static void print_trace(void); |
|
28 |
+static void sigsegv(int sig); |
|
29 |
+ |
|
30 |
+static void |
|
31 |
+sigsegv(int sig) |
|
32 |
+{ |
|
33 |
+ signal(SIGSEGV, SIG_DFL); |
|
34 |
+ print_trace(); |
|
35 |
+ _exit(SIGSEGV); |
|
36 |
+} |
|
37 |
+ |
|
38 |
+static void |
|
39 |
+print_trace(void) |
|
40 |
+{ |
|
41 |
+#ifdef HAVE_BACKTRACE |
|
42 |
+ void *array[10]; |
|
43 |
+ size_t size, i; |
|
44 |
+ char **strings; |
|
45 |
+ |
|
46 |
+ puts("Segfault caught, backtrace:"); |
|
47 |
+ |
|
48 |
+ size = backtrace(array, 10); |
|
49 |
+ strings = backtrace_symbols(array, size); |
|
50 |
+ |
|
51 |
+ for(i = 0; i < size; i++) |
|
52 |
+ printf("\t%s\n", strings[i]); |
|
53 |
+ |
|
54 |
+ free(strings); |
|
55 |
+#endif |
|
56 |
+} |
|
57 |
+ |
|
58 |
+int |
|
59 |
+main(int argc, char **argv) |
|
60 |
+{ |
|
61 |
+ struct rlimit rlim; |
|
62 |
+ |
|
63 |
+ if(argc == 1) { |
|
64 |
+ fprintf(stderr, "Usage: %s files...\n", argv[0]); |
|
65 |
+ return 1; |
|
66 |
+ } |
|
67 |
+ rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY; |
|
68 |
+ if(setrlimit(RLIMIT_CORE, &rlim) < 0) |
|
69 |
+ perror("setrlimit"); |
|
70 |
+ |
|
71 |
+ if(mkdir("/tmp/mboxtest", 0750) < 0) { |
|
72 |
+ perror("/tmp/mboxtest"); |
|
73 |
+ return errno; |
|
74 |
+ } |
|
75 |
+ signal(SIGSEGV, sigsegv); |
|
76 |
+ while(*++argv) { |
|
77 |
+ int fd = open(*argv, 0); |
|
78 |
+ |
|
79 |
+ if(fd < 0) { |
|
80 |
+ perror(*argv); |
|
81 |
+ return errno; |
|
82 |
+ } |
|
83 |
+ printf("cl_mbox(%s) returns %d\n", |
|
84 |
+ *argv, cl_mbox("/tmp/mboxtest", fd)); |
|
85 |
+ close(fd); |
|
86 |
+ } |
|
87 |
+ puts("Finished - don't forget to rm -rf /tmp/mboxtest"); |
|
88 |
+ |
|
89 |
+ return 0; |
|
90 |
+} |
0 | 91 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,177 @@ |
0 |
+/* |
|
1 |
+ * $CC -DHAVE_CONFIG_H $CFLAGS -I../.. debugpe.c -lclamav -lefence (or what |
|
2 |
+ * ever memory debugger) |
|
3 |
+ * If you're going to use HAVE_BACKTRACE, ensure CFLAGS includes -g and doesn't |
|
4 |
+ * include -fomit-frame-pointer |
|
5 |
+ * |
|
6 |
+ * njh@bandsman.co.uk |
|
7 |
+ */ |
|
8 |
+#include <stdio.h> |
|
9 |
+#include <errno.h> |
|
10 |
+#include <sys/stat.h> |
|
11 |
+#include <sys/types.h> |
|
12 |
+#include <fcntl.h> |
|
13 |
+#include <malloc.h> |
|
14 |
+#include <clamav.h> |
|
15 |
+#include <sys/resource.h> |
|
16 |
+#include <signal.h> |
|
17 |
+#include <features.h> |
|
18 |
+#include <memory.h> |
|
19 |
+#include <unistd.h> |
|
20 |
+ |
|
21 |
+#include "clamav-config.h" |
|
22 |
+#include "libclamav/others.h" |
|
23 |
+#include "libclamav/pe.h" |
|
24 |
+ |
|
25 |
+#if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 |
|
26 |
+/*#define HAVE_BACKTRACE /* Only tested on Linux... */ |
|
27 |
+#endif |
|
28 |
+ |
|
29 |
+#ifdef HAVE_BACKTRACE |
|
30 |
+#include <execinfo.h> |
|
31 |
+#endif |
|
32 |
+ |
|
33 |
+static const uint16_t test1[] = { |
|
34 |
+ 0x5a4d, 0x0090, 0x0003, 0x0000, 0x0004, 0x0000, 0xffff, 0x0000, |
|
35 |
+ 0x00b8, 0x0000, 0x0000, 0x0000, 0x0040, 0x0000, 0x0000, 0x0000, |
|
36 |
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
|
37 |
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0100, 0x0000, |
|
38 |
+ 0x1f0e, 0x0eba, 0xb400, 0xcd09, 0xb821, 0x4c01, 0x21cd, 0x6854, |
|
39 |
+ 0x7369, 0x7020, 0x6f72, 0x7267, 0x6d61, 0x6320, 0x6e61, 0x6f6e, |
|
40 |
+ 0x2074, 0x6562, 0x7220, 0x6e75, 0x6920, 0x206e, 0x4f44, 0x2053, |
|
41 |
+ 0x6f6d, 0x6564, 0x0d2e, 0x0a0d, 0x0024, 0x0000, 0x0000, 0x0000, |
|
42 |
+ 0x07c2, 0x23b9, 0x6686, 0x70d7, 0x6686, 0x70d7, 0x6686, 0x70d7, |
|
43 |
+ 0x6a83, 0x7088, 0x668f, 0x70d7, 0x6e05, 0x7088, 0x6687, 0x70d7 |
|
44 |
+}; |
|
45 |
+static const uint16_t test2[] = { |
|
46 |
+ 0x5a4d, 0x0090, 0x0003, 0x0000, 0x0004, 0x0000, 0xffff, 0x0000, |
|
47 |
+ 0x00b8, 0x0000, 0x0000, 0x0000, 0x0040, 0x0000, 0x0000, 0x0000, |
|
48 |
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
|
49 |
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0100, 0x0000, |
|
50 |
+ 0x1f0e, 0x0eba, 0xb400, 0xcd09, 0xb821, 0x4c01, 0x21cd, 0x6854, |
|
51 |
+ 0x7369, 0x7020, 0x6f72, 0x7267, 0x6d61, 0x6320, 0x6e61, 0x6f6e, |
|
52 |
+ 0x2074, 0x6562, 0x7220, 0x6e75, 0x6920, 0x206e, 0x4f44, 0x2053, |
|
53 |
+ 0x6f6d, 0x6564, 0x0d2e, 0x0a0d, 0x0024, 0x0000, 0x0000, 0x0000, |
|
54 |
+ 0x07c2, 0x23b9, 0x6686, 0x70d7, 0x6686, 0x70d7, 0x6686, 0x70d7, |
|
55 |
+ 0x6a82, 0x7088, 0x668f, 0x70d7, 0x6e05, 0x7088, 0x6687, 0x70d7 |
|
56 |
+}; |
|
57 |
+static const uint16_t test3[] = { |
|
58 |
+ 0x5a4d, 0x0091, 0x0003, 0x0000, 0x0004, 0x0000, 0xffff, 0x0000, |
|
59 |
+ 0x00b8, 0x0000, 0x0000, 0x0000, 0x0040, 0x0000, 0x0000, 0x0000, |
|
60 |
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
|
61 |
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0100, 0x0000, |
|
62 |
+ 0x1f0e, 0x0eba, 0xb400, 0xcd09, 0xb821, 0x4c01, 0x21cd, 0x6854, |
|
63 |
+ 0x7369, 0x7020, 0x6f72, 0x7267, 0x6d61, 0x6320, 0x6e61, 0x6f6e, |
|
64 |
+ 0x2074, 0x6562, 0x7220, 0x6e75, 0x6920, 0x206e, 0x4f44, 0x2053, |
|
65 |
+ 0x6f6d, 0x6564, 0x0d2e, 0x0a0d, 0x0024, 0x0000, 0x0000, 0x0000, |
|
66 |
+ 0x07c2, 0x23b9, 0x6686, 0x70d7, 0x6686, 0x70d7, 0x6686, 0x70d7, |
|
67 |
+ 0x6a83, 0x7088, 0x668f, 0x70d7, 0x6e05, 0x7088, 0x6687, 0x70d7 |
|
68 |
+}; |
|
69 |
+static const uint16_t test4[] = { |
|
70 |
+ 0x5a4d, 0x0090, 0x0003, 0x0000, 0x0004, 0x0000, 0xffff, 0x0000, |
|
71 |
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
|
72 |
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0100, 0x0000, |
|
73 |
+ 0x1f0e, 0x0eba, 0xb400, 0xcd09, 0xb821, 0x4c01, 0x21cd, 0x6854, |
|
74 |
+ 0x7369, 0x7020, 0x6f72, 0x7267, 0x6d61, 0x6320, 0x6e61, 0x6f6e, |
|
75 |
+ 0x2074, 0x6562, 0x7220, 0x6e75, 0x6920, 0x206e, 0x4f44, 0x2053, |
|
76 |
+ 0x6f6d, 0x6564, 0x0d2e, 0x0a0d, 0x0024, 0x0000, 0x0000, 0x0000, |
|
77 |
+ 0x07c2, 0x23b9, 0x6686, 0x70d7, 0x6686, 0x70d7, 0x6686, 0x70d7, |
|
78 |
+ 0x6a83, 0x7088, 0x668f, 0x70d7, 0x6e05, 0x7088, 0x6687, 0x70d7 |
|
79 |
+}; |
|
80 |
+ |
|
81 |
+static struct tests { |
|
82 |
+ const uint16_t *test; |
|
83 |
+ unsigned int size; |
|
84 |
+} tests[] = { |
|
85 |
+ { test1, sizeof(test1) }, |
|
86 |
+ { test2, sizeof(test2) }, |
|
87 |
+ { test3, sizeof(test3) }, |
|
88 |
+ { test4, sizeof(test4) }, |
|
89 |
+ { NULL, 0 }, |
|
90 |
+}; |
|
91 |
+ |
|
92 |
+static const char *tmp_file = "/tmp/petest"; |
|
93 |
+ |
|
94 |
+static void print_trace(void); |
|
95 |
+static void sigsegv(int sig); |
|
96 |
+ |
|
97 |
+static void |
|
98 |
+sigsegv(int sig) |
|
99 |
+{ |
|
100 |
+ signal(SIGSEGV, SIG_DFL); |
|
101 |
+ print_trace(); |
|
102 |
+ _exit(SIGSEGV); |
|
103 |
+} |
|
104 |
+ |
|
105 |
+static void |
|
106 |
+print_trace(void) |
|
107 |
+{ |
|
108 |
+#ifdef HAVE_BACKTRACE |
|
109 |
+ void *array[10]; |
|
110 |
+ size_t size, i; |
|
111 |
+ char **strings; |
|
112 |
+ |
|
113 |
+ puts("Segfault caught, backtrace:"); |
|
114 |
+ |
|
115 |
+ size = backtrace(array, 10); |
|
116 |
+ strings = backtrace_symbols(array, size); |
|
117 |
+ |
|
118 |
+ for(i = 0; i < size; i++) |
|
119 |
+ printf("\t%s\n", strings[i]); |
|
120 |
+ |
|
121 |
+ free(strings); |
|
122 |
+#endif |
|
123 |
+} |
|
124 |
+ |
|
125 |
+int |
|
126 |
+main(int argc, char **argv) |
|
127 |
+{ |
|
128 |
+ const struct tests *t; |
|
129 |
+ int fd; |
|
130 |
+ struct rlimit rlim; |
|
131 |
+ cli_ctx ctx; |
|
132 |
+ |
|
133 |
+ rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY; |
|
134 |
+ if(setrlimit(RLIMIT_CORE, &rlim) < 0) |
|
135 |
+ perror("setrlimit"); |
|
136 |
+ |
|
137 |
+ memset(&ctx, '\0', sizeof(cli_ctx)); |
|
138 |
+ /*printf("cl_scanpe(-1) returns %d\n", cli_scanpe(-1, &ctx)); |
|
139 |
+ printf("cl_scanpe(10) returns %d\n", cli_scanpe(10, &ctx)); |
|
140 |
+ printf("cl_scanpe(10000) returns %d\n", cli_scanpe(10000, &ctx));*/ |
|
141 |
+ cli_scanpe(-1, &ctx); |
|
142 |
+ cli_scanpe(-1, NULL); |
|
143 |
+ cli_scanpe(10, &ctx); |
|
144 |
+ cli_scanpe(10, NULL); |
|
145 |
+ cli_scanpe(10000, &ctx); |
|
146 |
+ cli_scanpe(10000, NULL); |
|
147 |
+ |
|
148 |
+ for(t = tests; t->test; t++) { |
|
149 |
+ int n; |
|
150 |
+ |
|
151 |
+ for(n = t->size; n >= 1; --n) { |
|
152 |
+ int m; |
|
153 |
+ |
|
154 |
+ for(m = 0; m < n; m++) { |
|
155 |
+ fd = open(tmp_file, O_CREAT|O_RDWR, 0600); |
|
156 |
+ |
|
157 |
+ if(fd < 0) { |
|
158 |
+ perror(tmp_file); |
|
159 |
+ return errno; |
|
160 |
+ } |
|
161 |
+ |
|
162 |
+ write(fd, &t->test[m], n - m); |
|
163 |
+ |
|
164 |
+ signal(SIGSEGV, sigsegv); |
|
165 |
+ |
|
166 |
+ memset(&ctx, '\0', sizeof(cli_ctx)); |
|
167 |
+ cli_scanpe(fd, &ctx); |
|
168 |
+ cli_scanpe(fd, NULL); |
|
169 |
+ /*printf("cl_scanpe() returns %d\n", cli_scanpe(fd, &ctx));*/ |
|
170 |
+ close(fd); |
|
171 |
+ } |
|
172 |
+ } |
|
173 |
+ } |
|
174 |
+ |
|
175 |
+ return unlink(tmp_file); |
|
176 |
+} |
12 | 189 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,23 @@ |
0 |
+all: clam-v2.rar clam-v3.rar clam.cab clam.exe.bz2 clam.exe clam.zip |
|
1 |
+ |
|
2 |
+clam-v2.rar: |
|
3 |
+ $(SED) 's/\(.\)\(.\)/\2\1/g' <.reversed/clam-v2.rar.reversed >clam-v2.rar |
|
4 |
+ |
|
5 |
+clam-v3.rar: |
|
6 |
+ $(SED) 's/\(.\)\(.\)/\2\1/g' <.reversed/clam-v3.rar.reversed >clam-v3.rar |
|
7 |
+ |
|
8 |
+clam.cab: |
|
9 |
+ $(SED) 's/\(.\)\(.\)/\2\1/g' <.reversed/clam.cab.reversed >clam.cab |
|
10 |
+ |
|
11 |
+clam.exe.bz2: |
|
12 |
+ $(SED) 's/\(.\)\(.\)/\2\1/g' <.reversed/clam.exe.bz2.reversed >clam.exe.bz2 |
|
13 |
+ |
|
14 |
+clam.exe: |
|
15 |
+ $(SED) 's/\(.\)\(.\)/\2\1/g' <.reversed/clam.exe.reversed >clam.exe |
|
16 |
+ |
|
17 |
+clam.zip: |
|
18 |
+ $(SED) 's/\(.\)\(.\)/\2\1/g' <.reversed/clam.zip.reversed >clam.zip |
|
19 |
+ |
|
20 |
+clean: |
|
21 |
+ rm -f clam-v2.rar clam-v3.rar clam.cab clam.exe.bz2 clam.exe clam.zip |
|
22 |
+ |
0 | 23 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,353 @@ |
0 |
+# Makefile.in generated by automake 1.10 from Makefile.am. |
|
1 |
+# @configure_input@ |
|
2 |
+ |
|
3 |
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, |
|
4 |
+# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
|
5 |
+# This Makefile.in is free software; the Free Software Foundation |
|
6 |
+# gives unlimited permission to copy and/or distribute it, |
|
7 |
+# with or without modifications, as long as this notice is preserved. |
|
8 |
+ |
|
9 |
+# This program is distributed in the hope that it will be useful, |
|
10 |
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without |
|
11 |
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
|
12 |
+# PARTICULAR PURPOSE. |
|
13 |
+ |
|
14 |
+@SET_MAKE@ |
|
15 |
+VPATH = @srcdir@ |
|
16 |
+pkgdatadir = $(datadir)/@PACKAGE@ |
|
17 |
+pkglibdir = $(libdir)/@PACKAGE@ |
|
18 |
+pkgincludedir = $(includedir)/@PACKAGE@ |
|
19 |
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd |
|
20 |
+install_sh_DATA = $(install_sh) -c -m 644 |
|
21 |
+install_sh_PROGRAM = $(install_sh) -c |
|
22 |
+install_sh_SCRIPT = $(install_sh) -c |
|
23 |
+INSTALL_HEADER = $(INSTALL_DATA) |
|
24 |
+transform = $(program_transform_name) |
|
25 |
+NORMAL_INSTALL = : |
|
26 |
+PRE_INSTALL = : |
|
27 |
+POST_INSTALL = : |
|
28 |
+NORMAL_UNINSTALL = : |
|
29 |
+PRE_UNINSTALL = : |
|
30 |
+POST_UNINSTALL = : |
|
31 |
+build_triplet = @build@ |
|
32 |
+host_triplet = @host@ |
|
33 |
+target_triplet = @target@ |
|
34 |
+subdir = test |
|
35 |
+DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in |
|
36 |
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
|
37 |
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ |
|
38 |
+ $(top_srcdir)/configure.in |
|
39 |
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ |
|
40 |
+ $(ACLOCAL_M4) |
|
41 |
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs |
|
42 |
+CONFIG_HEADER = $(top_builddir)/clamav-config.h |
|
43 |
+CONFIG_CLEAN_FILES = |
|
44 |
+SOURCES = |
|
45 |
+DIST_SOURCES = |
|
46 |
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) |
|
47 |
+ACLOCAL = @ACLOCAL@ |
|
48 |
+AMTAR = @AMTAR@ |
|
49 |
+AR = @AR@ |
|
50 |
+AUTOCONF = @AUTOCONF@ |
|
51 |
+AUTOHEADER = @AUTOHEADER@ |
|
52 |
+AUTOMAKE = @AUTOMAKE@ |
|
53 |
+AWK = @AWK@ |
|
54 |
+CC = @CC@ |
|
55 |
+CCDEPMODE = @CCDEPMODE@ |
|
56 |
+CFGDIR = @CFGDIR@ |
|
57 |
+CFLAGS = @CFLAGS@ |
|
58 |
+CLAMAVGROUP = @CLAMAVGROUP@ |
|
59 |
+CLAMAVUSER = @CLAMAVUSER@ |
|
60 |
+CLAMAV_MILTER_LIBS = @CLAMAV_MILTER_LIBS@ |
|
61 |
+CLAMD_LIBS = @CLAMD_LIBS@ |
|
62 |
+CPP = @CPP@ |
|
63 |
+CPPFLAGS = @CPPFLAGS@ |
|
64 |
+CYGPATH_W = @CYGPATH_W@ |
|
65 |
+DBDIR = @DBDIR@ |
|
66 |
+DEFS = @DEFS@ |
|
67 |
+DEPDIR = @DEPDIR@ |
|
68 |
+ECHO = @ECHO@ |
|
69 |
+ECHO_C = @ECHO_C@ |
|
70 |
+ECHO_N = @ECHO_N@ |
|
71 |
+ECHO_T = @ECHO_T@ |
|
72 |
+EGREP = @EGREP@ |
|
73 |
+EXEEXT = @EXEEXT@ |
|
74 |
+FRESHCLAM_LIBS = @FRESHCLAM_LIBS@ |
|
75 |
+GETENT = @GETENT@ |
|
76 |
+GREP = @GREP@ |
|
77 |
+INSTALL = @INSTALL@ |
|
78 |
+INSTALL_DATA = @INSTALL_DATA@ |
|
79 |
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ |
|
80 |
+INSTALL_SCRIPT = @INSTALL_SCRIPT@ |
|
81 |
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ |
|
82 |
+LDFLAGS = @LDFLAGS@ |
|
83 |
+LIBCLAMAV_LIBS = @LIBCLAMAV_LIBS@ |
|
84 |
+LIBCLAMAV_VERSION = @LIBCLAMAV_VERSION@ |
|
85 |
+LIBOBJS = @LIBOBJS@ |
|
86 |
+LIBS = @LIBS@ |
|
87 |
+LIBTOOL = @LIBTOOL@ |
|
88 |
+LN_S = @LN_S@ |
|
89 |
+LTLIBOBJS = @LTLIBOBJS@ |
|
90 |
+MAINT = @MAINT@ |
|
91 |
+MAKEINFO = @MAKEINFO@ |
|
92 |
+MKDIR_P = @MKDIR_P@ |
|
93 |
+OBJEXT = @OBJEXT@ |
|
94 |
+PACKAGE = @PACKAGE@ |
|
95 |
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ |
|
96 |
+PACKAGE_NAME = @PACKAGE_NAME@ |
|
97 |
+PACKAGE_STRING = @PACKAGE_STRING@ |
|
98 |
+PACKAGE_TARNAME = @PACKAGE_TARNAME@ |
|
99 |
+PACKAGE_VERSION = @PACKAGE_VERSION@ |
|
100 |
+PATH_SEPARATOR = @PATH_SEPARATOR@ |
|
101 |
+RANLIB = @RANLIB@ |
|
102 |
+SED = @SED@ |
|
103 |
+SET_MAKE = @SET_MAKE@ |
|
104 |
+SHELL = @SHELL@ |
|
105 |
+STRIP = @STRIP@ |
|
106 |
+THREAD_LIBS = @THREAD_LIBS@ |
|
107 |
+TH_SAFE = @TH_SAFE@ |
|
108 |
+VERSION = @VERSION@ |
|
109 |
+VERSIONSCRIPTFLAG = @VERSIONSCRIPTFLAG@ |
|
110 |
+abs_builddir = @abs_builddir@ |
|
111 |
+abs_srcdir = @abs_srcdir@ |
|
112 |
+abs_top_builddir = @abs_top_builddir@ |
|
113 |
+abs_top_srcdir = @abs_top_srcdir@ |
|
114 |
+ac_ct_CC = @ac_ct_CC@ |
|
115 |
+am__include = @am__include@ |
|
116 |
+am__leading_dot = @am__leading_dot@ |
|
117 |
+am__quote = @am__quote@ |
|
118 |
+am__tar = @am__tar@ |
|
119 |
+am__untar = @am__untar@ |
|
120 |
+bindir = @bindir@ |
|
121 |
+build = @build@ |
|
122 |
+build_alias = @build_alias@ |
|
123 |
+build_cpu = @build_cpu@ |
|
124 |
+build_os = @build_os@ |
|
125 |
+build_vendor = @build_vendor@ |
|
126 |
+builddir = @builddir@ |
|
127 |
+datadir = @datadir@ |
|
128 |
+datarootdir = @datarootdir@ |
|
129 |
+docdir = @docdir@ |
|
130 |
+dvidir = @dvidir@ |
|
131 |
+exec_prefix = @exec_prefix@ |
|
132 |
+host = @host@ |
|
133 |
+host_alias = @host_alias@ |
|
134 |
+host_cpu = @host_cpu@ |
|
135 |
+host_os = @host_os@ |
|
136 |
+host_vendor = @host_vendor@ |
|
137 |
+htmldir = @htmldir@ |
|
138 |
+includedir = @includedir@ |
|
139 |
+infodir = @infodir@ |
|
140 |
+install_sh = @install_sh@ |
|
141 |
+libdir = @libdir@ |
|
142 |
+libexecdir = @libexecdir@ |
|
143 |
+localedir = @localedir@ |
|
144 |
+localstatedir = @localstatedir@ |
|
145 |
+mandir = @mandir@ |
|
146 |
+mkdir_p = @mkdir_p@ |
|
147 |
+oldincludedir = @oldincludedir@ |
|
148 |
+pdfdir = @pdfdir@ |
|
149 |
+prefix = @prefix@ |
|
150 |
+program_transform_name = @program_transform_name@ |
|
151 |
+psdir = @psdir@ |
|
152 |
+sbindir = @sbindir@ |
|
153 |
+sendmailprog = @sendmailprog@ |
|
154 |
+sharedstatedir = @sharedstatedir@ |
|
155 |
+srcdir = @srcdir@ |
|
156 |
+sysconfdir = @sysconfdir@ |
|
157 |
+target = @target@ |
|
158 |
+target_alias = @target_alias@ |
|
159 |
+target_cpu = @target_cpu@ |
|
160 |
+target_os = @target_os@ |
|
161 |
+target_vendor = @target_vendor@ |
|
162 |
+top_builddir = @top_builddir@ |
|
163 |
+top_srcdir = @top_srcdir@ |
|
164 |
+all: all-am |
|
165 |
+ |
|
166 |
+.SUFFIXES: |
|
167 |
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) |
|
168 |
+ @for dep in $?; do \ |
|
169 |
+ case '$(am__configure_deps)' in \ |
|
170 |
+ *$$dep*) \ |
|
171 |
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ |
|
172 |
+ && exit 0; \ |
|
173 |
+ exit 1;; \ |
|
174 |
+ esac; \ |
|
175 |
+ done; \ |
|
176 |
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/Makefile'; \ |
|
177 |
+ cd $(top_srcdir) && \ |
|
178 |
+ $(AUTOMAKE) --gnu test/Makefile |
|
179 |
+.PRECIOUS: Makefile |
|
180 |
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status |
|
181 |
+ @case '$?' in \ |
|
182 |
+ *config.status*) \ |
|
183 |
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ |
|
184 |
+ *) \ |
|
185 |
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ |
|
186 |
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ |
|
187 |
+ esac; |
|
188 |
+ |
|
189 |
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) |
|
190 |
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh |
|
191 |
+ |
|
192 |
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) |
|
193 |
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh |
|
194 |
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) |
|
195 |
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh |
|
196 |
+ |
|
197 |
+mostlyclean-libtool: |
|
198 |
+ -rm -f *.lo |
|
199 |
+ |
|
200 |
+clean-libtool: |
|
201 |
+ -rm -rf .libs _libs |
|
202 |
+tags: TAGS |
|
203 |
+TAGS: |
|
204 |
+ |
|
205 |
+ctags: CTAGS |
|
206 |
+CTAGS: |
|
207 |
+ |
|
208 |
+ |
|
209 |
+distdir: $(DISTFILES) |
|
210 |
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ |
|
211 |
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ |
|
212 |
+ list='$(DISTFILES)'; \ |
|
213 |
+ dist_files=`for file in $$list; do echo $$file; done | \ |
|
214 |
+ sed -e "s|^$$srcdirstrip/||;t" \ |
|
215 |
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ |
|
216 |
+ case $$dist_files in \ |
|
217 |
+ */*) $(MKDIR_P) `echo "$$dist_files" | \ |
|
218 |
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ |
|
219 |
+ sort -u` ;; \ |
|
220 |
+ esac; \ |
|
221 |
+ for file in $$dist_files; do \ |
|
222 |
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ |
|
223 |
+ if test -d $$d/$$file; then \ |
|
224 |
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ |
|
225 |
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ |
|
226 |
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ |
|
227 |
+ fi; \ |
|
228 |
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ |
|
229 |
+ else \ |
|
230 |
+ test -f $(distdir)/$$file \ |
|
231 |
+ || cp -p $$d/$$file $(distdir)/$$file \ |
|
232 |
+ || exit 1; \ |
|
233 |
+ fi; \ |
|
234 |
+ done |
|
235 |
+check-am: all-am |
|
236 |
+check: check-am |
|
237 |
+all-am: Makefile |
|
238 |
+installdirs: |
|
239 |
+install: install-am |
|
240 |
+install-exec: install-exec-am |
|
241 |
+install-data: install-data-am |
|
242 |
+uninstall: uninstall-am |
|
243 |
+ |
|
244 |
+install-am: all-am |
|
245 |
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am |
|
246 |
+ |
|
247 |
+installcheck: installcheck-am |
|
248 |
+install-strip: |
|
249 |
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ |
|
250 |
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ |
|
251 |
+ `test -z '$(STRIP)' || \ |
|
252 |
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install |
|
253 |
+mostlyclean-generic: |
|
254 |
+ |
|
255 |
+clean-generic: |
|
256 |
+ |
|
257 |
+distclean-generic: |
|
258 |
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) |
|
259 |
+ |
|
260 |
+maintainer-clean-generic: |
|
261 |
+ @echo "This command is intended for maintainers to use" |
|
262 |
+ @echo "it deletes files that may require special tools to rebuild." |
|
263 |
+clean-am: clean-generic clean-libtool mostlyclean-am |
|
264 |
+ |
|
265 |
+distclean: distclean-am |
|
266 |
+ -rm -f Makefile |
|
267 |
+distclean-am: clean-am distclean-generic |
|
268 |
+ |
|
269 |
+dvi: dvi-am |
|
270 |
+ |
|
271 |
+dvi-am: |
|
272 |
+ |
|
273 |
+html: html-am |
|
274 |
+ |
|
275 |
+info: info-am |
|
276 |
+ |
|
277 |
+info-am: |
|
278 |
+ |
|
279 |
+install-data-am: |
|
280 |
+ |
|
281 |
+install-dvi: install-dvi-am |
|
282 |
+ |
|
283 |
+install-exec-am: |
|
284 |
+ |
|
285 |
+install-html: install-html-am |
|
286 |
+ |
|
287 |
+install-info: install-info-am |
|
288 |
+ |
|
289 |
+install-man: |
|
290 |
+ |
|
291 |
+install-pdf: install-pdf-am |
|
292 |
+ |
|
293 |
+install-ps: install-ps-am |
|
294 |
+ |
|
295 |
+installcheck-am: |
|
296 |
+ |
|
297 |
+maintainer-clean: maintainer-clean-am |
|
298 |
+ -rm -f Makefile |
|
299 |
+maintainer-clean-am: distclean-am maintainer-clean-generic |
|
300 |
+ |
|
301 |
+mostlyclean: mostlyclean-am |
|
302 |
+ |
|
303 |
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool |
|
304 |
+ |
|
305 |
+pdf: pdf-am |
|
306 |
+ |
|
307 |
+pdf-am: |
|
308 |
+ |
|
309 |
+ps: ps-am |
|
310 |
+ |
|
311 |
+ps-am: |
|
312 |
+ |
|
313 |
+uninstall-am: |
|
314 |
+ |
|
315 |
+.MAKE: install-am install-strip |
|
316 |
+ |
|
317 |
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \ |
|
318 |
+ distclean distclean-generic distclean-libtool distdir dvi \ |
|
319 |
+ dvi-am html html-am info info-am install install-am \ |
|
320 |
+ install-data install-data-am install-dvi install-dvi-am \ |
|
321 |
+ install-exec install-exec-am install-html install-html-am \ |
|
322 |
+ install-info install-info-am install-man install-pdf \ |
|
323 |
+ install-pdf-am install-ps install-ps-am install-strip \ |
|
324 |
+ installcheck installcheck-am installdirs maintainer-clean \ |
|
325 |
+ maintainer-clean-generic mostlyclean mostlyclean-generic \ |
|
326 |
+ mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am |
|
327 |
+ |
|
328 |
+all: clam-v2.rar clam-v3.rar clam.cab clam.exe.bz2 clam.exe clam.zip |
|
329 |
+ |
|
330 |
+clam-v2.rar: |
|
331 |
+ $(SED) 's/\(.\)\(.\)/\2\1/g' <.reversed/clam-v2.rar.reversed >clam-v2.rar |
|
332 |
+ |
|
333 |
+clam-v3.rar: |
|
334 |
+ $(SED) 's/\(.\)\(.\)/\2\1/g' <.reversed/clam-v3.rar.reversed >clam-v3.rar |
|
335 |
+ |
|
336 |
+clam.cab: |
|
337 |
+ $(SED) 's/\(.\)\(.\)/\2\1/g' <.reversed/clam.cab.reversed >clam.cab |
|
338 |
+ |
|
339 |
+clam.exe.bz2: |
|
340 |
+ $(SED) 's/\(.\)\(.\)/\2\1/g' <.reversed/clam.exe.bz2.reversed >clam.exe.bz2 |
|
341 |
+ |
|
342 |
+clam.exe: |
|
343 |
+ $(SED) 's/\(.\)\(.\)/\2\1/g' <.reversed/clam.exe.reversed >clam.exe |
|
344 |
+ |
|
345 |
+clam.zip: |
|
346 |
+ $(SED) 's/\(.\)\(.\)/\2\1/g' <.reversed/clam.zip.reversed >clam.zip |
|
347 |
+ |
|
348 |
+clean: |
|
349 |
+ rm -f clam-v2.rar clam-v3.rar clam.cab clam.exe.bz2 clam.exe clam.zip |
|
350 |
+# Tell versions [3.59,3.63) of GNU make to not export all variables. |
|
351 |
+# Otherwise a system limit (for SysV at least) may be exceeded. |
|
352 |
+.NOEXPORT: |
... | ... |
@@ -1,3 +1,7 @@ |
1 | 1 |
clam.exe is an extremely small (544 bytes!) MZ+PE executable that prints |
2 | 2 |
a nice message :-) You can use it to test attachment scanning in your ClamAV |
3 | 3 |
based mail scanner. |
4 |
+ |
|
5 |
+NOTE: upon request the testfiles are now shipped byteswapped. |
|
6 |
+The real files are generated dynamically by make. |
|
7 |
+ |
16 | 20 |
deleted file mode 100644 |
... | ... |
@@ -1,374 +0,0 @@ |
1 |
-/* |
|
2 |
- * Copyright (C) 2007 Nigel Horne <njh@bandsman.co.uk> |
|
3 |
- * |
|
4 |
- * This program is free software; you can redistribute it and/or modify |
|
5 |
- * it under the terms of the GNU General Public License as published by |
|
6 |
- * the Free Software Foundation; either version 2 of the License, or |
|
7 |
- * (at your option) any later version. |
|
8 |
- * |
|
9 |
- * This program is distributed in the hope that it will be useful, |
|
10 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
- * GNU General Public License for more details. |
|
13 |
- * |
|
14 |
- * You should have received a copy of the GNU General Public License |
|
15 |
- * along with this program; if not, write to the Free Software |
|
16 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
17 |
- * MA 02110-1301, USA. |
|
18 |
- * |
|
19 |
- * Compare the results of scanning files on a set of machines |
|
20 |
- * This is useful for regression testing versions, and for testing |
|
21 |
- * across different operating systems and architectures |
|
22 |
- * The file is always copied which is slow, and could be removed for regression |
|
23 |
- * testing, if we have some mechanism to sync the data |
|
24 |
- */ |
|
25 |
- |
|
26 |
-#include <stdio.h> |
|
27 |
-#include <stdlib.h> |
|
28 |
-#include <sys/types.h> |
|
29 |
-#include <dirent.h> |
|
30 |
-#include <sys/socket.h> |
|
31 |
-#include <netinet/in.h> |
|
32 |
-#include <arpa/inet.h> |
|
33 |
-#include <netdb.h> |
|
34 |
-#include <memory.h> |
|
35 |
-#include <unistd.h> |
|
36 |
-#include <pthread.h> |
|
37 |
-#include <string.h> |
|
38 |
-#include <signal.h> |
|
39 |
- |
|
40 |
-#define PORT 3310 |
|
41 |
-#define LEN 128 |
|
42 |
- |
|
43 |
-/* |
|
44 |
- * Ensure you don't have StreamMaxLength on any of the servers, or that it's |
|
45 |
- * big enough for all your samples |
|
46 |
- * Uses SESSIONS, which isn't good |
|
47 |
- * If localhost is one of them, it's probably best to put it last so that it |
|
48 |
- * can be scanning while waiting for the remote machines to respond |
|
49 |
- */ |
|
50 |
-static struct machine { |
|
51 |
- const char *name; |
|
52 |
- in_addr_t ip; |
|
53 |
- int sock; |
|
54 |
-} machines[] = { |
|
55 |
- { "eric", 0, -1 }, |
|
56 |
- /*{ "motorola", 0, -1 },*/ |
|
57 |
- /*{ "ultra60", 0, -1 },*/ |
|
58 |
- { "mac", 0, -1 }, |
|
59 |
- { "localhost", 0, -1 }, |
|
60 |
- { NULL, 0, -1 } |
|
61 |
-}; |
|
62 |
- |
|
63 |
-struct args { |
|
64 |
- const char *filename; |
|
65 |
- const struct machine *m; |
|
66 |
- char *ret; |
|
67 |
-}; |
|
68 |
- |
|
69 |
-static void dir(const char *dirname); |
|
70 |
-static in_addr_t resolve(const char *machine); |
|
71 |
-static int start(in_addr_t ip); |
|
72 |
-static void *scan(void *v); |
|
73 |
- |
|
74 |
-int |
|
75 |
-main(int argc, char **argv) |
|
76 |
-{ |
|
77 |
- struct machine *m; |
|
78 |
- |
|
79 |
- if(argc <= 1) { |
|
80 |
- fputs("Arg count\n", stderr); |
|
81 |
- return 1; |
|
82 |
- } |
|
83 |
- |
|
84 |
- for(m = machines; m->name; m++) { |
|
85 |
- m->ip = resolve(m->name); |
|
86 |
- |
|
87 |
- if(m->ip == INADDR_NONE) { |
|
88 |
- fprintf(stderr, "Can't resolve %s\n", m->name); |
|
89 |
- return 1; |
|
90 |
- } |
|
91 |
- m->sock = start(m->ip); |
|
92 |
- if(m->sock < 0) |
|
93 |
- fprintf(stderr, "%s is down\n", m->name); |
|
94 |
- } |
|
95 |
- |
|
96 |
- signal(SIGPIPE, SIG_IGN); |
|
97 |
- |
|
98 |
- while(*++argv) |
|
99 |
- dir(*argv); |
|
100 |
- |
|
101 |
- return 0; |
|
102 |
-} |
|
103 |
- |
|
104 |
-static void |
|
105 |
-dir(const char *dirname) |
|
106 |
-{ |
|
107 |
- int i, nmachines; |
|
108 |
- const struct dirent *dirent; |
|
109 |
- struct machine *m; |
|
110 |
- DIR *d = opendir(dirname); |
|
111 |
- char **results; |
|
112 |
- |
|
113 |
- if(d == NULL) { |
|
114 |
- perror(dirname); |
|
115 |
- return; |
|
116 |
- } |
|
117 |
- for(nmachines = 0, m = machines; m->name; m++) |
|
118 |
- if(m->sock >= 0) |
|
119 |
- nmachines++; |
|
120 |
- |
|
121 |
- if(nmachines < 2) { |
|
122 |
- fputs("Needs at least 2 machines up to run\n", stderr); |
|
123 |
- closedir(d); |
|
124 |
- return; |
|
125 |
- } |
|
126 |
- |
|
127 |
- results = (char **)malloc(nmachines * sizeof(char *)); |
|
128 |
- if(results == NULL) |
|
129 |
- return; |
|
130 |
- for(i = 0, m = machines; m->name; m++) |
|
131 |
- if(m->sock >= 0) { |
|
132 |
- results[i] = malloc(LEN); |
|
133 |
- if(results[i++] == NULL) { |
|
134 |
- free(results); |
|
135 |
- closedir(d); |
|
136 |
- return; |
|
137 |
- } |
|
138 |
- } |
|
139 |
- |
|
140 |
- if(i != nmachines) { |
|
141 |
- fputs("Failed sanity check\n", stderr); |
|
142 |
- closedir(d); |
|
143 |
- return; |
|
144 |
- } |
|
145 |
- |
|
146 |
- while((dirent = readdir(d)) != NULL) { |
|
147 |
- int nthreads, founddiffs; |
|
148 |
- pthread_t *tids; |
|
149 |
- struct args *args; |
|
150 |
- char name[PATH_MAX]; |
|
151 |
- |
|
152 |
- if(dirent->d_ino == (ino_t)0) |
|
153 |
- continue; |
|
154 |
- if(dirent->d_name[0] == '.') |
|
155 |
- continue; |
|
156 |
- |
|
157 |
- tids = malloc(nmachines * sizeof(pthread_t)); |
|
158 |
- if(tids == NULL) { |
|
159 |
- free(results); |
|
160 |
- closedir(d); |
|
161 |
- return; |
|
162 |
- } |
|
163 |
- args = malloc(nmachines * sizeof(struct args)); |
|
164 |
- if(args == NULL) { |
|
165 |
- free(tids); |
|
166 |
- free(results); |
|
167 |
- closedir(d); |
|
168 |
- return; |
|
169 |
- } |
|
170 |
- |
|
171 |
- snprintf(name, sizeof(name) -1, "%s/%s", dirname, dirent->d_name); |
|
172 |
- for(nthreads = 0, m = machines; m->name; m++) { |
|
173 |
- if(m->sock < 0) |
|
174 |
- continue; |
|
175 |
- |
|
176 |
- args[nthreads].filename = name; |
|
177 |
- args[nthreads].m = m; |
|
178 |
- args[nthreads].ret = results[nthreads]; |
|
179 |
- pthread_create(&tids[nthreads], NULL, scan, &args[nthreads]); |
|
180 |
- nthreads++; |
|
181 |
- } |
|
182 |
- /*printf("Scanning %s\n", name);*/ |
|
183 |
- founddiffs = 0; |
|
184 |
- while(--nthreads >= 0) |
|
185 |
- /* TODO: timeout */ |
|
186 |
- pthread_join(tids[nthreads], NULL); |
|
187 |
- |
|
188 |
- free(args); |
|
189 |
- free(tids); |
|
190 |
- for(i = 0; i <= nmachines - 2; i++) { |
|
191 |
- int j; |
|
192 |
- |
|
193 |
- for(j = i + 1; j <= nmachines - 1; j++) { |
|
194 |
- const char *s, *t; |
|
195 |
- |
|
196 |
- s = strchr(results[i], ' '); |
|
197 |
- t = strchr(results[j], ' '); |
|
198 |
- if((s == NULL) || (t == NULL) || (strcmp(s, t) != 0)) { |
|
199 |
- printf("%s:\n", name); |
|
200 |
- printf("\t%s: %s\n", machines[i].name, s ? s : "null"); |
|
201 |
- printf("\t%s: %s\n", machines[j].name, t ? t : "null"); |
|
202 |
- founddiffs = 1; |
|
203 |
- } |
|
204 |
- } |
|
205 |
- } |
|
206 |
- |
|
207 |
- /*if(!founddiffs) |
|
208 |
- printf("%s passed\n", name);*/ |
|
209 |
- } |
|
210 |
- closedir(d); |
|
211 |
-} |
|
212 |
- |
|
213 |
-static in_addr_t |
|
214 |
-resolve(const char *machine) |
|
215 |
-{ |
|
216 |
- in_addr_t ret = inet_addr(machine); |
|
217 |
- |
|
218 |
- if(ret == INADDR_NONE) { |
|
219 |
- const struct hostent *h = gethostbyname(machine); |
|
220 |
- |
|
221 |
- if(h == NULL) { |
|
222 |
- fprintf(stderr, "Unknown host %s\n", machine); |
|
223 |
- return INADDR_NONE; |
|
224 |
- } |
|
225 |
- |
|
226 |
- memcpy((char *)&ret, h->h_addr, sizeof(in_addr_t)); |
|
227 |
- } |
|
228 |
- return ret; |
|
229 |
-} |
|
230 |
- |
|
231 |
-static int |
|
232 |
-start(in_addr_t ip) |
|
233 |
-{ |
|
234 |
- int sock; |
|
235 |
- const struct protoent *proto; |
|
236 |
- struct sockaddr_in server; |
|
237 |
- |
|
238 |
- memset((char *)&server, 0, sizeof(struct sockaddr_in)); |
|
239 |
- server.sin_family = AF_INET; |
|
240 |
- server.sin_port = (in_port_t)htons(PORT); |
|
241 |
- server.sin_addr.s_addr = ip; |
|
242 |
- |
|
243 |
- proto = getprotobyname("tcp"); |
|
244 |
- if(proto == NULL) { |
|
245 |
- fputs("Unknown prototol tcp, check /etc/protocols\n", stderr); |
|
246 |
- return -1; |
|
247 |
- } else if((sock = socket(AF_INET, SOCK_STREAM, proto->p_proto)) < 0) { |
|
248 |
- perror("socket"); |
|
249 |
- return -1; |
|
250 |
- } else if(connect(sock, (struct sockaddr *)&server, sizeof(struct sockaddr_in)) < 0) { |
|
251 |
- perror("connect"); |
|
252 |
- close(sock); |
|
253 |
- return -1; |
|
254 |
- } else if(send(sock, "SESSION\n", 8, 0) < 8) { |
|
255 |
- perror("send"); |
|
256 |
- close(sock); |
|
257 |
- return -1; |
|
258 |
- } |
|
259 |
- return sock; |
|
260 |
-} |
|
261 |
- |
|
262 |
-static void * |
|
263 |
-scan(void *v) |
|
264 |
-{ |
|
265 |
- struct args *args; |
|
266 |
- FILE *fin; |
|
267 |
- int sock; |
|
268 |
- ssize_t nbytes; |
|
269 |
- size_t buflen; |
|
270 |
- in_port_t port; |
|
271 |
- struct sockaddr_in data; |
|
272 |
- const struct machine *m; |
|
273 |
- char buf[1024]; /* must be less than MTU */ |
|
274 |
- |
|
275 |
- args = (struct args *)v; |
|
276 |
- m = args->m; |
|
277 |
- if(m->sock < 0) |
|
278 |
- return NULL; |
|
279 |
- if(m->ip == htonl(INADDR_LOOPBACK)) { |
|
280 |
- char cmd[NAME_MAX + 7]; |
|
281 |
- |
|
282 |
- snprintf(cmd, sizeof(cmd) - 1, "SCAN %s\n", args->filename); |
|
283 |
- buflen = strlen(cmd); |
|
284 |
- |
|
285 |
- if(send(m->sock, cmd, buflen, 0) != (ssize_t)buflen) { |
|
286 |
- perror(m->name); |
|
287 |
- return NULL; |
|
288 |
- } |
|
289 |
- nbytes = recv(m->sock, args->ret, LEN, 0); |
|
290 |
- if(nbytes < 0) { |
|
291 |
- perror(m->name); |
|
292 |
- return NULL; |
|
293 |
- } |
|
294 |
- args->ret[nbytes - 1] = '\0'; /* remove the trailing \n */ |
|
295 |
- |
|
296 |
- return NULL; |
|
297 |
- } |
|
298 |
- fin = fopen(args->filename, "r"); |
|
299 |
- if(fin == NULL) { |
|
300 |
- perror(args->filename); |
|
301 |
- return NULL; |
|
302 |
- } |
|
303 |
- if(send(m->sock, "STREAM\n", 7, 0) != 7) { |
|
304 |
- perror(m->name); |
|
305 |
- fclose(fin); |
|
306 |
- return NULL; |
|
307 |
- } |
|
308 |
- |
|
309 |
- if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { |
|
310 |
- perror("socket"); |
|
311 |
- fputs("Failed to create TCPSocket to talk to clamd\n", stderr); |
|
312 |
- fclose(fin); |
|
313 |
- return NULL; |
|
314 |
- } |
|
315 |
- |
|
316 |
- nbytes = recv(m->sock, buf, sizeof(buf), 0); |
|
317 |
- if(nbytes <= 0) { |
|
318 |
- perror(m->name); |
|
319 |
- close(sock); |
|
320 |
- fclose(fin); |
|
321 |
- return NULL; |
|
322 |
- } |
|
323 |
- buf[nbytes] = '\0'; |
|
324 |
- |
|
325 |
- if(sscanf(buf, "PORT %hu\n", &port) != 1) { |
|
326 |
- fprintf(stderr, "Expected port information from clamd, got '%s'", |
|
327 |
- buf); |
|
328 |
- close(sock); |
|
329 |
- fclose(fin); |
|
330 |
- return NULL; |
|
331 |
- } |
|
332 |
- |
|
333 |
- memset((char *)&data, 0, sizeof(struct sockaddr_in)); |
|
334 |
- data.sin_family = AF_INET; |
|
335 |
- data.sin_port = (in_port_t)htons(port); |
|
336 |
- data.sin_addr.s_addr = m->ip; |
|
337 |
- |
|
338 |
- if(connect(sock, (struct sockaddr *)&data, sizeof(struct sockaddr_in)) < 0) { |
|
339 |
- perror(m->name); |
|
340 |
- fprintf(stderr, "Couldn't connect to port %d\n", port); |
|
341 |
- close(sock); |
|
342 |
- fclose(fin); |
|
343 |
- return NULL; |
|
344 |
- } |
|
345 |
- |
|
346 |
- shutdown(sock, SHUT_RD); |
|
347 |
- |
|
348 |
- while((buflen = fread(buf, 1, sizeof(buf), fin)) > 0) { |
|
349 |
- ssize_t sent = send(sock, buf, buflen, 0); |
|
350 |
- |
|
351 |
- if(sent != (ssize_t)buflen) { |
|
352 |
- /* Probably hit scanstream len */ |
|
353 |
- if(sent < 0) |
|
354 |
- perror(m->name); |
|
355 |
- else |
|
356 |
- fprintf(stderr, "%s: only sent %d bytes of %d to %s\n", |
|
357 |
- args->filename, sent, buflen, m->name); |
|
358 |
- break; |
|
359 |
- } |
|
360 |
- } |
|
361 |
- |
|
362 |
- close(sock); |
|
363 |
- fclose(fin); |
|
364 |
- |
|
365 |
- /* TODO: timeout */ |
|
366 |
- nbytes = recv(m->sock, args->ret, LEN, 0); |
|
367 |
- if(nbytes < 0) { |
|
368 |
- perror(m->name); |
|
369 |
- return NULL; |
|
370 |
- } |
|
371 |
- args->ret[(nbytes) ? (nbytes - 1) : 0] = '\0'; /* remove the trailing \n */ |
|
372 |
- |
|
373 |
- return NULL; |
|
374 |
-} |
375 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,313 +0,0 @@ |
1 |
-/* |
|
2 |
- * Copyright (C) 2006 Nigel Horne <njh@bandsman.co.uk> |
|
3 |
- * |
|
4 |
- * This program is free software; you can redistribute it and/or modify |
|
5 |
- * it under the terms of the GNU General Public License as published by |
|
6 |
- * the Free Software Foundation; either version 2 of the License, or |
|
7 |
- * (at your option) any later version. |
|
8 |
- * |
|
9 |
- * This program is distributed in the hope that it will be useful, |
|
10 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
- * GNU General Public License for more details. |
|
13 |
- * |
|
14 |
- * You should have received a copy of the GNU General Public License |
|
15 |
- * along with this program; if not, write to the Free Software |
|
16 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
17 |
- * MA 02110-1301, USA. |
|
18 |
- * |
|
19 |
- * $CC $CFLAGS -I../.. -I../../libclamav debugm.c -lclamav |
|
20 |
- * Now try a.out /sbin/* or a.out /usr/bin/* |
|
21 |
- * |
|
22 |
- * njh@bandsman.co.uk |
|
23 |
- */ |
|
24 |
-#include <stdio.h> |
|
25 |
-#include <errno.h> |
|
26 |
-#include <sys/stat.h> |
|
27 |
-#include <sys/types.h> |
|
28 |
-#include <fcntl.h> |
|
29 |
-#include <malloc.h> |
|
30 |
-#include <clamav.h> |
|
31 |
-#include <sys/resource.h> |
|
32 |
-#include <features.h> |
|
33 |
-#include <unistd.h> |
|
34 |
-#include <memory.h> |
|
35 |
-#include <pthread.h> |
|
36 |
-#include "clamav-config.h" |
|
37 |
-#include "others.h" |
|
38 |
-#include "mbox.h" |
|
39 |
-#include "pdf.h" |
|
40 |
-#include "binhex.h" |
|
41 |
-#include "untar.h" |
|
42 |
-#include "special.h" |
|
43 |
-#include "tnef.h" |
|
44 |
-#include "pst.h" |
|
45 |
-#include "pe.h" |
|
46 |
- |
|
47 |
-struct args { |
|
48 |
- cli_ctx ctx; |
|
49 |
- const char *filename; |
|
50 |
-}; |
|
51 |
- |
|
52 |
-static void * |
|
53 |
-mbox(void *v) |
|
54 |
-{ |
|
55 |
- struct args *args = (struct args *)v; |
|
56 |
- int fd = open(args->filename, O_RDONLY); |
|
57 |
- |
|
58 |
- if(fd < 0) { |
|
59 |
- perror(args->filename); |
|
60 |
- return NULL; |
|
61 |
- } |
|
62 |
- printf("cl_mbox(%s) returns %d\n", |
|
63 |
- args->filename, cli_mbox("/tmp/libclamav", fd, &args->ctx)); |
|
64 |
- close(fd); |
|
65 |
- |
|
66 |
- return NULL; |
|
67 |
-} |
|
68 |
- |
|
69 |
-static void * |
|
70 |
-pdf(void *v) |
|
71 |
-{ |
|
72 |
- struct args *args = (struct args *)v; |
|
73 |
- int fd = open(args->filename, O_RDONLY); |
|
74 |
- |
|
75 |
- if(fd < 0) { |
|
76 |
- perror(args->filename); |
|
77 |
- return NULL; |
|
78 |
- } |
|
79 |
- printf("cl_pdf(%s) returns %d\n", |
|
80 |
- args->filename, cli_pdf("/tmp/libclamav", fd, &args->ctx)); |
|
81 |
- close(fd); |
|
82 |
- |
|
83 |
- return NULL; |
|
84 |
-} |
|
85 |
- |
|
86 |
-static void * |
|
87 |
-scandir(void *v) |
|
88 |
-{ |
|
89 |
- struct args *args = (struct args *)v; |
|
90 |
- int fd = open(args->filename, O_RDONLY); |
|
91 |
- |
|
92 |
- if(fd < 0) { |
|
93 |
- perror(args->filename); |
|
94 |
- return NULL; |
|
95 |
- } |
|
96 |
- printf("cl_scandir(%s) returns %d\n", |
|
97 |
- args->filename, cli_scandir("/tmp/libclamav", &args->ctx)); |
|
98 |
- close(fd); |
|
99 |
- |
|
100 |
- return NULL; |
|
101 |
-} |
|
102 |
- |
|
103 |
-static void * |
|
104 |
-untar(void *v) |
|
105 |
-{ |
|
106 |
- struct args *args = (struct args *)v; |
|
107 |
- int fd = open(args->filename, O_RDONLY); |
|
108 |
- |
|
109 |
- if(fd < 0) { |
|
110 |
- perror(args->filename); |
|
111 |
- return NULL; |
|
112 |
- } |
|
113 |
- printf("cl_untar(%s) returns %d\n", |
|
114 |
- args->filename, cli_untar("/tmp/libclamav", fd, 1)); |
|
115 |
- close(fd); |
|
116 |
- |
|
117 |
- return NULL; |
|
118 |
-} |
|
119 |
- |
|
120 |
-static void * |
|
121 |
-binhex(void *v) |
|
122 |
-{ |
|
123 |
- struct args *args = (struct args *)v; |
|
124 |
- int fd = open(args->filename, O_RDONLY); |
|
125 |
- |
|
126 |
- if(fd < 0) { |
|
127 |
- perror(args->filename); |
|
128 |
- return NULL; |
|
129 |
- } |
|
130 |
- printf("cl_binhex(%s) returns %d\n", |
|
131 |
- args->filename, cli_binhex("/tmp/libclamav", fd)); |
|
132 |
- close(fd); |
|
133 |
- |
|
134 |
- return NULL; |
|
135 |
-} |
|
136 |
- |
|
137 |
-static void * |
|
138 |
-jpeg(void *v) |
|
139 |
-{ |
|
140 |
- struct args *args = (struct args *)v; |
|
141 |
- int fd = open(args->filename, O_RDONLY); |
|
142 |
- |
|
143 |
- if(fd < 0) { |
|
144 |
- perror(args->filename); |
|
145 |
- return NULL; |
|
146 |
- } |
|
147 |
- printf("cli_check_jpeg_exploit(%s) returns %d\n", |
|
148 |
- args->filename, cli_check_jpeg_exploit(fd)); |
|
149 |
- close(fd); |
|
150 |
- |
|
151 |
- return NULL; |
|
152 |
-} |
|
153 |
- |
|
154 |
-static void * |
|
155 |
-tnef(void *v) |
|
156 |
-{ |
|
157 |
- struct args *args = (struct args *)v; |
|
158 |
- int fd = open(args->filename, O_RDONLY); |
|
159 |
- |
|
160 |
- if(fd < 0) { |
|
161 |
- perror(args->filename); |
|
162 |
- return NULL; |
|
163 |
- } |
|
164 |
- printf("cli_tnef(%s) returns %d\n", |
|
165 |
- args->filename, cli_tnef("/tmp/libclamav", fd)); |
|
166 |
- close(fd); |
|
167 |
- |
|
168 |
- return NULL; |
|
169 |
-} |
|
170 |
- |
|
171 |
-static void * |
|
172 |
-uuencode(void *v) |
|
173 |
-{ |
|
174 |
- struct args *args = (struct args *)v; |
|
175 |
- int fd = open(args->filename, O_RDONLY); |
|
176 |
- |
|
177 |
- if(fd < 0) { |
|
178 |
- perror(args->filename); |
|
179 |
- return NULL; |
|
180 |
- } |
|
181 |
- printf("cli_uuencode(%s) returns %d\n", |
|
182 |
- args->filename, cli_uuencode("/tmp/libclamav", fd)); |
|
183 |
- close(fd); |
|
184 |
- |
|
185 |
- return NULL; |
|
186 |
-} |
|
187 |
- |
|
188 |
-static void * |
|
189 |
-pst(void *v) |
|
190 |
-{ |
|
191 |
- struct args *args = (struct args *)v; |
|
192 |
- int fd = open(args->filename, O_RDONLY); |
|
193 |
- |
|
194 |
- if(fd < 0) { |
|
195 |
- perror(args->filename); |
|
196 |
- return NULL; |
|
197 |
- } |
|
198 |
- printf("cli_pst(%s) returns %d\n", |
|
199 |
- args->filename, cli_pst("/tmp/libclamav", fd)); |
|
200 |
- close(fd); |
|
201 |
- |
|
202 |
- return NULL; |
|
203 |
-} |
|
204 |
- |
|
205 |
-static void * |
|
206 |
-pe(void *v) |
|
207 |
-{ |
|
208 |
- struct args *args = (struct args *)v; |
|
209 |
- int fd = open(args->filename, O_RDONLY); |
|
210 |
- |
|
211 |
- if(fd < 0) { |
|
212 |
- perror(args->filename); |
|
213 |
- return NULL; |
|
214 |
- } |
|
215 |
- printf("cli_scanpe(%s) returns %d\n", |
|
216 |
- args->filename, cli_scanpe(fd, &args->ctx)); |
|
217 |
- close(fd); |
|
218 |
- |
|
219 |
- return NULL; |
|
220 |
-} |
|
221 |
- |
|
222 |
-int |
|
223 |
-main(int argc, char **argv) |
|
224 |
-{ |
|
225 |
- struct rlimit rlim; |
|
226 |
- const char *virname; |
|
227 |
- struct cl_engine engine; |
|
228 |
- struct cl_limits limits; |
|
229 |
- unsigned long scanned; |
|
230 |
- struct args args; |
|
231 |
- |
|
232 |
- if(argc == 1) { |
|
233 |
- fprintf(stderr, "Usage: %s files...\n", argv[0]); |
|
234 |
- return 1; |
|
235 |
- } |
|
236 |
- rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY; |
|
237 |
- if(setrlimit(RLIMIT_CORE, &rlim) < 0) |
|
238 |
- perror("setrlimit"); |
|
239 |
- |
|
240 |
- if((mkdir("/tmp/libclamav", 0750) < 0) && (errno != EEXIST)) { |
|
241 |
- perror("/tmp/libclamav"); |
|
242 |
- return errno; |
|
243 |
- } |
|
244 |
- |
|
245 |
- memset(&args.ctx, '\0', sizeof(cli_ctx)); |
|
246 |
- args.ctx.engine = &engine; |
|
247 |
- args.ctx.virname = &virname; |
|
248 |
- args.ctx.limits = &limits; |
|
249 |
- args.ctx.scanned = &scanned; |
|
250 |
- args.ctx.options = 0; |
|
251 |
- |
|
252 |
- while(*++argv) { |
|
253 |
- pthread_t t; |
|
254 |
- |
|
255 |
- args.filename = *argv; |
|
256 |
- |
|
257 |
- if(pthread_create(&t, NULL, mbox, &args) != 0) |
|
258 |
- perror("pthread_create"); |
|
259 |
- if(pthread_detach(t) != 0) |
|
260 |
- perror("pthread_detach"); |
|
261 |
- |
|
262 |
- if(pthread_create(&t, NULL, pdf, &args) != 0) |
|
263 |
- perror("pthread_create"); |
|
264 |
- if(pthread_detach(t) != 0) |
|
265 |
- perror("pthread_detach"); |
|
266 |
- |
|
267 |
- if(pthread_create(&t, NULL, untar, &args) != 0) |
|
268 |
- perror("pthread_create"); |
|
269 |
- if(pthread_detach(t) != 0) |
|
270 |
- perror("pthread_detach"); |
|
271 |
- |
|
272 |
- if(pthread_create(&t, NULL, binhex, &args) != 0) |
|
273 |
- perror("pthread_create"); |
|
274 |
- if(pthread_detach(t) != 0) |
|
275 |
- perror("pthread_detach"); |
|
276 |
- |
|
277 |
- if(pthread_create(&t, NULL, jpeg, &args) != 0) |
|
278 |
- perror("pthread_create"); |
|
279 |
- if(pthread_detach(t) != 0) |
|
280 |
- perror("pthread_detach"); |
|
281 |
- |
|
282 |
- if(pthread_create(&t, NULL, tnef, &args) != 0) |
|
283 |
- perror("pthread_create"); |
|
284 |
- if(pthread_detach(t) != 0) |
|
285 |
- perror("pthread_detach"); |
|
286 |
- |
|
287 |
- if(pthread_create(&t, NULL, uuencode, &args) != 0) |
|
288 |
- perror("pthread_create"); |
|
289 |
- if(pthread_detach(t) != 0) |
|
290 |
- perror("pthread_detach"); |
|
291 |
- |
|
292 |
- if(pthread_create(&t, NULL, pst, &args) != 0) |
|
293 |
- perror("pthread_create"); |
|
294 |
- if(pthread_detach(t) != 0) |
|
295 |
- perror("pthread_detach"); |
|
296 |
- |
|
297 |
- if(pthread_create(&t, NULL, pe, &args) != 0) |
|
298 |
- perror("pthread_create"); |
|
299 |
- if(pthread_detach(t) != 0) |
|
300 |
- perror("pthread_detach"); |
|
301 |
- |
|
302 |
- /* TODO: pass through all in cli_magic_scandesc */ |
|
303 |
- if(pthread_create(&t, NULL, scandir, &args) != 0) |
|
304 |
- perror("pthread_create"); |
|
305 |
- if(pthread_detach(t) != 0) |
|
306 |
- perror("pthread_detach"); |
|
307 |
- } |
|
308 |
- puts("Hit SIGINT when all is finished"); |
|
309 |
- pause(); |
|
310 |
- puts("Finished - don't forget to rm -rf /tmp/libclamav"); |
|
311 |
- |
|
312 |
- return 0; |
|
313 |
-} |
314 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,91 +0,0 @@ |
1 |
-/* |
|
2 |
- * $CC $CFLAGS -I../.. debugm.c -lclamav -lefence (or what ever memory debugger) |
|
3 |
- * If you're going to use HAVE_BACKTRACE, ensure CFLAGS includes -g and doesn't |
|
4 |
- * include -fomit-frame-pointer |
|
5 |
- * |
|
6 |
- * njh@bandsman.co.uk |
|
7 |
- */ |
|
8 |
-#include <stdio.h> |
|
9 |
-#include <errno.h> |
|
10 |
-#include <sys/stat.h> |
|
11 |
-#include <sys/types.h> |
|
12 |
-#include <fcntl.h> |
|
13 |
-#include <malloc.h> |
|
14 |
-#include <clamav.h> |
|
15 |
-#include <sys/resource.h> |
|
16 |
-#include <signal.h> |
|
17 |
-#include <features.h> |
|
18 |
-#include "clamav-config.h" |
|
19 |
- |
|
20 |
-#if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 |
|
21 |
-/*#define HAVE_BACKTRACE /* Only tested on Linux... */ |
|
22 |
-#endif |
|
23 |
- |
|
24 |
-#ifdef HAVE_BACKTRACE |
|
25 |
-#include <execinfo.h> |
|
26 |
-#endif |
|
27 |
- |
|
28 |
-static void print_trace(void); |
|
29 |
-static void sigsegv(int sig); |
|
30 |
- |
|
31 |
-static void |
|
32 |
-sigsegv(int sig) |
|
33 |
-{ |
|
34 |
- signal(SIGSEGV, SIG_DFL); |
|
35 |
- print_trace(); |
|
36 |
- _exit(SIGSEGV); |
|
37 |
-} |
|
38 |
- |
|
39 |
-static void |
|
40 |
-print_trace(void) |
|
41 |
-{ |
|
42 |
-#ifdef HAVE_BACKTRACE |
|
43 |
- void *array[10]; |
|
44 |
- size_t size, i; |
|
45 |
- char **strings; |
|
46 |
- |
|
47 |
- puts("Segfault caught, backtrace:"); |
|
48 |
- |
|
49 |
- size = backtrace(array, 10); |
|
50 |
- strings = backtrace_symbols(array, size); |
|
51 |
- |
|
52 |
- for(i = 0; i < size; i++) |
|
53 |
- printf("\t%s\n", strings[i]); |
|
54 |
- |
|
55 |
- free(strings); |
|
56 |
-#endif |
|
57 |
-} |
|
58 |
- |
|
59 |
-int |
|
60 |
-main(int argc, char **argv) |
|
61 |
-{ |
|
62 |
- struct rlimit rlim; |
|
63 |
- |
|
64 |
- if(argc == 1) { |
|
65 |
- fprintf(stderr, "Usage: %s files...\n", argv[0]); |
|
66 |
- return 1; |
|
67 |
- } |
|
68 |
- rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY; |
|
69 |
- if(setrlimit(RLIMIT_CORE, &rlim) < 0) |
|
70 |
- perror("setrlimit"); |
|
71 |
- |
|
72 |
- if(mkdir("/tmp/mboxtest", 0750) < 0) { |
|
73 |
- perror("/tmp/mboxtest"); |
|
74 |
- return errno; |
|
75 |
- } |
|
76 |
- signal(SIGSEGV, sigsegv); |
|
77 |
- while(*++argv) { |
|
78 |
- int fd = open(*argv, 0); |
|
79 |
- |
|
80 |
- if(fd < 0) { |
|
81 |
- perror(*argv); |
|
82 |
- return errno; |
|
83 |
- } |
|
84 |
- printf("cl_mbox(%s) returns %d\n", |
|
85 |
- *argv, cl_mbox("/tmp/mboxtest", fd)); |
|
86 |
- close(fd); |
|
87 |
- } |
|
88 |
- puts("Finished - don't forget to rm -rf /tmp/mboxtest"); |
|
89 |
- |
|
90 |
- return 0; |
|
91 |
-} |
92 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,177 +0,0 @@ |
1 |
-/* |
|
2 |
- * $CC -DHAVE_CONFIG_H $CFLAGS -I../.. debugpe.c -lclamav -lefence (or what |
|
3 |
- * ever memory debugger) |
|
4 |
- * If you're going to use HAVE_BACKTRACE, ensure CFLAGS includes -g and doesn't |
|
5 |
- * include -fomit-frame-pointer |
|
6 |
- * |
|
7 |
- * njh@bandsman.co.uk |
|
8 |
- */ |
|
9 |
-#include <stdio.h> |
|
10 |
-#include <errno.h> |
|
11 |
-#include <sys/stat.h> |
|
12 |
-#include <sys/types.h> |
|
13 |
-#include <fcntl.h> |
|
14 |
-#include <malloc.h> |
|
15 |
-#include <clamav.h> |
|
16 |
-#include <sys/resource.h> |
|
17 |
-#include <signal.h> |
|
18 |
-#include <features.h> |
|
19 |
-#include <memory.h> |
|
20 |
-#include <unistd.h> |
|
21 |
- |
|
22 |
-#include "clamav-config.h" |
|
23 |
-#include "libclamav/others.h" |
|
24 |
-#include "libclamav/pe.h" |
|
25 |
- |
|
26 |
-#if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 |
|
27 |
-/*#define HAVE_BACKTRACE /* Only tested on Linux... */ |
|
28 |
-#endif |
|
29 |
- |
|
30 |
-#ifdef HAVE_BACKTRACE |
|
31 |
-#include <execinfo.h> |
|
32 |
-#endif |
|
33 |
- |
|
34 |
-static const uint16_t test1[] = { |
|
35 |
- 0x5a4d, 0x0090, 0x0003, 0x0000, 0x0004, 0x0000, 0xffff, 0x0000, |
|
36 |
- 0x00b8, 0x0000, 0x0000, 0x0000, 0x0040, 0x0000, 0x0000, 0x0000, |
|
37 |
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
|
38 |
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0100, 0x0000, |
|
39 |
- 0x1f0e, 0x0eba, 0xb400, 0xcd09, 0xb821, 0x4c01, 0x21cd, 0x6854, |
|
40 |
- 0x7369, 0x7020, 0x6f72, 0x7267, 0x6d61, 0x6320, 0x6e61, 0x6f6e, |
|
41 |
- 0x2074, 0x6562, 0x7220, 0x6e75, 0x6920, 0x206e, 0x4f44, 0x2053, |
|
42 |
- 0x6f6d, 0x6564, 0x0d2e, 0x0a0d, 0x0024, 0x0000, 0x0000, 0x0000, |
|
43 |
- 0x07c2, 0x23b9, 0x6686, 0x70d7, 0x6686, 0x70d7, 0x6686, 0x70d7, |
|
44 |
- 0x6a83, 0x7088, 0x668f, 0x70d7, 0x6e05, 0x7088, 0x6687, 0x70d7 |
|
45 |
-}; |
|
46 |
-static const uint16_t test2[] = { |
|
47 |
- 0x5a4d, 0x0090, 0x0003, 0x0000, 0x0004, 0x0000, 0xffff, 0x0000, |
|
48 |
- 0x00b8, 0x0000, 0x0000, 0x0000, 0x0040, 0x0000, 0x0000, 0x0000, |
|
49 |
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
|
50 |
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0100, 0x0000, |
|
51 |
- 0x1f0e, 0x0eba, 0xb400, 0xcd09, 0xb821, 0x4c01, 0x21cd, 0x6854, |
|
52 |
- 0x7369, 0x7020, 0x6f72, 0x7267, 0x6d61, 0x6320, 0x6e61, 0x6f6e, |
|
53 |
- 0x2074, 0x6562, 0x7220, 0x6e75, 0x6920, 0x206e, 0x4f44, 0x2053, |
|
54 |
- 0x6f6d, 0x6564, 0x0d2e, 0x0a0d, 0x0024, 0x0000, 0x0000, 0x0000, |
|
55 |
- 0x07c2, 0x23b9, 0x6686, 0x70d7, 0x6686, 0x70d7, 0x6686, 0x70d7, |
|
56 |
- 0x6a82, 0x7088, 0x668f, 0x70d7, 0x6e05, 0x7088, 0x6687, 0x70d7 |
|
57 |
-}; |
|
58 |
-static const uint16_t test3[] = { |
|
59 |
- 0x5a4d, 0x0091, 0x0003, 0x0000, 0x0004, 0x0000, 0xffff, 0x0000, |
|
60 |
- 0x00b8, 0x0000, 0x0000, 0x0000, 0x0040, 0x0000, 0x0000, 0x0000, |
|
61 |
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
|
62 |
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0100, 0x0000, |
|
63 |
- 0x1f0e, 0x0eba, 0xb400, 0xcd09, 0xb821, 0x4c01, 0x21cd, 0x6854, |
|
64 |
- 0x7369, 0x7020, 0x6f72, 0x7267, 0x6d61, 0x6320, 0x6e61, 0x6f6e, |
|
65 |
- 0x2074, 0x6562, 0x7220, 0x6e75, 0x6920, 0x206e, 0x4f44, 0x2053, |
|
66 |
- 0x6f6d, 0x6564, 0x0d2e, 0x0a0d, 0x0024, 0x0000, 0x0000, 0x0000, |
|
67 |
- 0x07c2, 0x23b9, 0x6686, 0x70d7, 0x6686, 0x70d7, 0x6686, 0x70d7, |
|
68 |
- 0x6a83, 0x7088, 0x668f, 0x70d7, 0x6e05, 0x7088, 0x6687, 0x70d7 |
|
69 |
-}; |
|
70 |
-static const uint16_t test4[] = { |
|
71 |
- 0x5a4d, 0x0090, 0x0003, 0x0000, 0x0004, 0x0000, 0xffff, 0x0000, |
|
72 |
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
|
73 |
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0100, 0x0000, |
|
74 |
- 0x1f0e, 0x0eba, 0xb400, 0xcd09, 0xb821, 0x4c01, 0x21cd, 0x6854, |
|
75 |
- 0x7369, 0x7020, 0x6f72, 0x7267, 0x6d61, 0x6320, 0x6e61, 0x6f6e, |
|
76 |
- 0x2074, 0x6562, 0x7220, 0x6e75, 0x6920, 0x206e, 0x4f44, 0x2053, |
|
77 |
- 0x6f6d, 0x6564, 0x0d2e, 0x0a0d, 0x0024, 0x0000, 0x0000, 0x0000, |
|
78 |
- 0x07c2, 0x23b9, 0x6686, 0x70d7, 0x6686, 0x70d7, 0x6686, 0x70d7, |
|
79 |
- 0x6a83, 0x7088, 0x668f, 0x70d7, 0x6e05, 0x7088, 0x6687, 0x70d7 |
|
80 |
-}; |
|
81 |
- |
|
82 |
-static struct tests { |
|
83 |
- const uint16_t *test; |
|
84 |
- unsigned int size; |
|
85 |
-} tests[] = { |
|
86 |
- { test1, sizeof(test1) }, |
|
87 |
- { test2, sizeof(test2) }, |
|
88 |
- { test3, sizeof(test3) }, |
|
89 |
- { test4, sizeof(test4) }, |
|
90 |
- { NULL, 0 }, |
|
91 |
-}; |
|
92 |
- |
|
93 |
-static const char *tmp_file = "/tmp/petest"; |
|
94 |
- |
|
95 |
-static void print_trace(void); |
|
96 |
-static void sigsegv(int sig); |
|
97 |
- |
|
98 |
-static void |
|
99 |
-sigsegv(int sig) |
|
100 |
-{ |
|
101 |
- signal(SIGSEGV, SIG_DFL); |
|
102 |
- print_trace(); |
|
103 |
- _exit(SIGSEGV); |
|
104 |
-} |
|
105 |
- |
|
106 |
-static void |
|
107 |
-print_trace(void) |
|
108 |
-{ |
|
109 |
-#ifdef HAVE_BACKTRACE |
|
110 |
- void *array[10]; |
|
111 |
- size_t size, i; |
|
112 |
- char **strings; |
|
113 |
- |
|
114 |
- puts("Segfault caught, backtrace:"); |
|
115 |
- |
|
116 |
- size = backtrace(array, 10); |
|
117 |
- strings = backtrace_symbols(array, size); |
|
118 |
- |
|
119 |
- for(i = 0; i < size; i++) |
|
120 |
- printf("\t%s\n", strings[i]); |
|
121 |
- |
|
122 |
- free(strings); |
|
123 |
-#endif |
|
124 |
-} |
|
125 |
- |
|
126 |
-int |
|
127 |
-main(int argc, char **argv) |
|
128 |
-{ |
|
129 |
- const struct tests *t; |
|
130 |
- int fd; |
|
131 |
- struct rlimit rlim; |
|
132 |
- cli_ctx ctx; |
|
133 |
- |
|
134 |
- rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY; |
|
135 |
- if(setrlimit(RLIMIT_CORE, &rlim) < 0) |
|
136 |
- perror("setrlimit"); |
|
137 |
- |
|
138 |
- memset(&ctx, '\0', sizeof(cli_ctx)); |
|
139 |
- /*printf("cl_scanpe(-1) returns %d\n", cli_scanpe(-1, &ctx)); |
|
140 |
- printf("cl_scanpe(10) returns %d\n", cli_scanpe(10, &ctx)); |
|
141 |
- printf("cl_scanpe(10000) returns %d\n", cli_scanpe(10000, &ctx));*/ |
|
142 |
- cli_scanpe(-1, &ctx); |
|
143 |
- cli_scanpe(-1, NULL); |
|
144 |
- cli_scanpe(10, &ctx); |
|
145 |
- cli_scanpe(10, NULL); |
|
146 |
- cli_scanpe(10000, &ctx); |
|
147 |
- cli_scanpe(10000, NULL); |
|
148 |
- |
|
149 |
- for(t = tests; t->test; t++) { |
|
150 |
- int n; |
|
151 |
- |
|
152 |
- for(n = t->size; n >= 1; --n) { |
|
153 |
- int m; |
|
154 |
- |
|
155 |
- for(m = 0; m < n; m++) { |
|
156 |
- fd = open(tmp_file, O_CREAT|O_RDWR, 0600); |
|
157 |
- |
|
158 |
- if(fd < 0) { |
|
159 |
- perror(tmp_file); |
|
160 |
- return errno; |
|
161 |
- } |
|
162 |
- |
|
163 |
- write(fd, &t->test[m], n - m); |
|
164 |
- |
|
165 |
- signal(SIGSEGV, sigsegv); |
|
166 |
- |
|
167 |
- memset(&ctx, '\0', sizeof(cli_ctx)); |
|
168 |
- cli_scanpe(fd, &ctx); |
|
169 |
- cli_scanpe(fd, NULL); |
|
170 |
- /*printf("cl_scanpe() returns %d\n", cli_scanpe(fd, &ctx));*/ |
|
171 |
- close(fd); |
|
172 |
- } |
|
173 |
- } |
|
174 |
- } |
|
175 |
- |
|
176 |
- return unlink(tmp_file); |
|
177 |
-} |