git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@386 77e5149b-7576-45b1-b177-96237e5ba77b
Tomasz Kojm authored on 2004/03/10 09:37:55... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Wed Mar 10 01:35:40 CET 2004 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * libclamav: unrarlib: cleanup (Dirk Mueller <dmuell*gmx.net>) |
|
4 |
+ |
|
1 | 5 |
Tue Mar 9 23:49:06 CET 2004 (tk) |
2 | 6 |
--------------------------------- |
3 | 7 |
* libclamav, sigtool: small code cleanups (Dirk Mueller <mueller*kde.org>) |
... | ... |
@@ -81,7 +81,7 @@ dnl there is now a CREATE_PREFIX_TARGET_H in this file as a shorthand for |
81 | 81 |
dnl PREFIX_CONFIG_H from a target.h file, however w/o the target.h ever created |
82 | 82 |
dnl (the prefix is a bit different, since we add an extra -target- and -host-) |
83 | 83 |
dnl |
84 |
-dnl @version: $Id: aclocal.m4,v 1.26 2004/03/05 13:26:22 kojm Exp $ |
|
84 |
+dnl @version: $Id: aclocal.m4,v 1.27 2004/03/10 00:37:55 kojm Exp $ |
|
85 | 85 |
dnl @author Guido Draheim <guidod@gmx.de> STATUS: used often |
86 | 86 |
|
87 | 87 |
AC_DEFUN([AC_CREATE_TARGET_H], |
... | ... |
@@ -4041,7 +4041,7 @@ dnl AC_COMPILE_CHECK_SIZEOF(ptrdiff_t, $headers) |
4041 | 4041 |
dnl AC_COMPILE_CHECK_SIZEOF(off_t, $headers) |
4042 | 4042 |
dnl |
4043 | 4043 |
dnl @author Kaveh Ghazi <ghazi@caip.rutgers.edu> |
4044 |
-dnl @version $Id: aclocal.m4,v 1.26 2004/03/05 13:26:22 kojm Exp $ |
|
4044 |
+dnl @version $Id: aclocal.m4,v 1.27 2004/03/10 00:37:55 kojm Exp $ |
|
4045 | 4045 |
dnl |
4046 | 4046 |
AC_DEFUN([AC_COMPILE_CHECK_SIZEOF], |
4047 | 4047 |
[changequote(<<, >>)dnl |
... | ... |
@@ -123,6 +123,9 @@ |
123 | 123 |
/* Define to 1 if you have the <stdlib.h> header file. */ |
124 | 124 |
#undef HAVE_STDLIB_H |
125 | 125 |
|
126 |
+/* Define to 1 if you have the `strerror_r' function. */ |
|
127 |
+#undef HAVE_STRERROR_R |
|
128 |
+ |
|
126 | 129 |
/* Define to 1 if you have the <strings.h> header file. */ |
127 | 130 |
#undef HAVE_STRINGS_H |
128 | 131 |
|
129 | 132 |
deleted file mode 100644 |
... | ... |
@@ -1,367 +0,0 @@ |
1 |
-/* |
|
2 |
- * Copyright (C) 2002 - 2004 Tomasz Kojm <tkojm@clamav.net> |
|
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., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
17 |
- */ |
|
18 |
- |
|
19 |
-#if HAVE_CONFIG_H |
|
20 |
-#include "clamav-config.h" |
|
21 |
-#endif |
|
22 |
- |
|
23 |
-#include <stdio.h> |
|
24 |
-#include <stdlib.h> |
|
25 |
-#include <string.h> |
|
26 |
-#include <unistd.h> |
|
27 |
-#include <sys/types.h> |
|
28 |
-#include <sys/socket.h> |
|
29 |
-#include <sys/wait.h> |
|
30 |
-#include <pthread.h> |
|
31 |
-#include <time.h> |
|
32 |
-#include <signal.h> |
|
33 |
- |
|
34 |
-#include "cfgfile.h" |
|
35 |
-#include "others.h" |
|
36 |
-#include "defaults.h" |
|
37 |
-#include "scanner.h" |
|
38 |
-#include "server.h" |
|
39 |
-#include "clamuko.h" |
|
40 |
-#include "tests.h" |
|
41 |
- |
|
42 |
-int sighup = 0; |
|
43 |
- |
|
44 |
-#define CMD1 "SCAN" |
|
45 |
-#define CMD2 "RAWSCAN" |
|
46 |
-#define CMD3 "QUIT" |
|
47 |
-#define CMD4 "RELOAD" |
|
48 |
-#define CMD5 "PING" |
|
49 |
-#define CMD6 "CONTSCAN" |
|
50 |
-#define CMD7 "VERSION" |
|
51 |
-#define CMD8 "STREAM" |
|
52 |
- |
|
53 |
-int procscan(const char *name, const struct cl_node *root, const struct cl_limits *limits, int options, const struct cfgstruct *copt, int odesc, short contscan) |
|
54 |
-{ |
|
55 |
- int pid; |
|
56 |
- struct cfgstruct *cpt; |
|
57 |
- |
|
58 |
- switch(pid = fork()) { |
|
59 |
- case -1: |
|
60 |
- logg("!Can't fork()\n"); |
|
61 |
- return -1; |
|
62 |
- |
|
63 |
- case 0: |
|
64 |
- if((cpt = cfgopt(copt, "ThreadTimeout"))) |
|
65 |
- alarm(cpt->numarg); |
|
66 |
-/* 0 should disable the limit |
|
67 |
- else |
|
68 |
- alarm(CL_DEFAULT_SCANTIMEOUT); |
|
69 |
-*/ |
|
70 |
- |
|
71 |
- if(!name) |
|
72 |
- scanstream(odesc, NULL, root, limits, options, copt); |
|
73 |
- else |
|
74 |
- scan(name, NULL, root, limits, options, copt, odesc, contscan); |
|
75 |
- |
|
76 |
- exit(0); |
|
77 |
- |
|
78 |
- default: |
|
79 |
- return pid; |
|
80 |
- } |
|
81 |
- |
|
82 |
- return -1; |
|
83 |
-} |
|
84 |
- |
|
85 |
-int acceptd = -1; |
|
86 |
- |
|
87 |
-int acceptloop_proc(int socketd, struct cl_node *root, const struct cfgstruct *copt) |
|
88 |
-{ |
|
89 |
- int i, j, bread, options = 0, childs, *session, status, |
|
90 |
- virnum, need_wait, ret; |
|
91 |
- struct cfgstruct *cpt; |
|
92 |
- struct cl_limits limits; |
|
93 |
- struct sigaction sigact; |
|
94 |
- char buff[1025]; |
|
95 |
- const char *dbdir; |
|
96 |
- sigset_t sigset; |
|
97 |
- mode_t old_umask; |
|
98 |
- |
|
99 |
- /* save the PID */ |
|
100 |
- if((cpt = cfgopt(copt, "PidFile"))) { |
|
101 |
- FILE *fd; |
|
102 |
- old_umask = umask(0006); |
|
103 |
- if((fd = fopen(cpt->strarg, "w")) == NULL) { |
|
104 |
- logg("!Can't save PID in file %s\n", cpt->strarg); |
|
105 |
- } else { |
|
106 |
- fprintf(fd, "%d", getpid()); |
|
107 |
- fclose(fd); |
|
108 |
- } |
|
109 |
- umask(old_umask); |
|
110 |
- } |
|
111 |
- |
|
112 |
- logg("*Listening daemon: PID: %d\n", getpid()); |
|
113 |
- |
|
114 |
- if((cpt = cfgopt(copt, "MaxThreads"))) |
|
115 |
- childs = cpt->numarg; |
|
116 |
- else |
|
117 |
- childs = CL_DEFAULT_MAXTHREADS; |
|
118 |
- |
|
119 |
- logg("Maximal number of childs: %d\n", childs); |
|
120 |
- session = (int *) mcalloc(childs, sizeof(int)); |
|
121 |
- |
|
122 |
- if((cpt = cfgopt(copt, "DatabaseDirectory")) || (cpt = cfgopt(copt, "DataDirectory"))) |
|
123 |
- dbdir = cpt->strarg; |
|
124 |
- else |
|
125 |
- dbdir = cl_retdbdir(); |
|
126 |
- |
|
127 |
- if(cfgopt(copt, "ScanArchive")) { |
|
128 |
- |
|
129 |
- /* set up limits */ |
|
130 |
- memset(&limits, 0, sizeof(struct cl_limits)); |
|
131 |
- |
|
132 |
- if((cpt = cfgopt(copt, "ArchiveMaxFileSize"))) { |
|
133 |
- if((limits.maxfilesize = cpt->numarg)) |
|
134 |
- logg("Archive: Archived file size limit set to %d bytes.\n", limits.maxfilesize); |
|
135 |
- else |
|
136 |
- logg("^Archive: File size limit protection disabled.\n"); |
|
137 |
- } else { |
|
138 |
- limits.maxfilesize = 10485760; |
|
139 |
- logg("^USING HARDCODED LIMIT: Archive: Archived file size limit set to %d bytes.\n", limits.maxfilesize); |
|
140 |
- } |
|
141 |
- |
|
142 |
- if((cpt = cfgopt(copt, "ArchiveMaxRecursion"))) { |
|
143 |
- if((limits.maxreclevel = cpt->numarg)) |
|
144 |
- logg("Archive: Recursion level limit set to %d.\n", limits.maxreclevel); |
|
145 |
- else |
|
146 |
- logg("^Archive: Recursion level limit protection disabled.\n"); |
|
147 |
- } else { |
|
148 |
- limits.maxreclevel = 5; |
|
149 |
- logg("^USING HARDCODED LIMIT: Archive: Recursion level set to %d.\n", limits.maxreclevel); |
|
150 |
- } |
|
151 |
- |
|
152 |
- if((cpt = cfgopt(copt, "ArchiveMaxFiles"))) { |
|
153 |
- if((limits.maxfiles = cpt->numarg)) |
|
154 |
- logg("Archive: Files limit set to %d.\n", limits.maxfiles); |
|
155 |
- else |
|
156 |
- logg("^Archive: Files limit protection disabled.\n"); |
|
157 |
- } else { |
|
158 |
- limits.maxfiles = 1000; |
|
159 |
- logg("^USING HARDCODED LIMIT: Archive: Files limit set to %d.\n", limits.maxfiles); |
|
160 |
- } |
|
161 |
- |
|
162 |
- if((cpt = cfgopt(copt, "ArchiveMaxCompressionRatio"))) { |
|
163 |
- if((limits.maxratio = cpt->numarg)) |
|
164 |
- logg("Archive: Compression ratio limit set to %d.\n", limits.maxratio); |
|
165 |
- else |
|
166 |
- logg("^Archive: Compression ratio limit disabled.\n"); |
|
167 |
- } else { |
|
168 |
- limits.maxratio = 200; |
|
169 |
- logg("^USING HARDCODED LIMIT: Archive: Compression ratio limit set to %d.\n", limits.maxratio); |
|
170 |
- } |
|
171 |
- |
|
172 |
- if(cfgopt(copt, "ArchiveLimitMemoryUsage")) { |
|
173 |
- limits.archivememlim = 1; |
|
174 |
- logg("Archive: Limited memory usage.\n"); |
|
175 |
- } else |
|
176 |
- limits.archivememlim = 0; |
|
177 |
- |
|
178 |
- |
|
179 |
- logg("Archive support enabled.\n"); |
|
180 |
- options |= CL_ARCHIVE; |
|
181 |
- |
|
182 |
- if(cfgopt(copt, "ScanRAR")) { |
|
183 |
- logg("RAR support enabled.\n"); |
|
184 |
- } else { |
|
185 |
- logg("RAR support disabled.\n"); |
|
186 |
- options |= CL_DISABLERAR; |
|
187 |
- } |
|
188 |
- |
|
189 |
- } else { |
|
190 |
- logg("Archive support disabled.\n"); |
|
191 |
- } |
|
192 |
- |
|
193 |
- if(cfgopt(copt, "ScanMail")) { |
|
194 |
- logg("Mail support enabled.\n"); |
|
195 |
- options |= CL_MAIL; |
|
196 |
- } else { |
|
197 |
- logg("Mail support disabled.\n"); |
|
198 |
- } |
|
199 |
- |
|
200 |
- if(cfgopt(copt, "ScanOLE2")) { |
|
201 |
- logg("OLE2 support enabled.\n"); |
|
202 |
- options |= CL_OLE2; |
|
203 |
- } else { |
|
204 |
- logg("OLE2 support disabled.\n"); |
|
205 |
- } |
|
206 |
- |
|
207 |
- /* set up signal handling */ |
|
208 |
- |
|
209 |
- sigfillset(&sigset); |
|
210 |
- sigdelset(&sigset, SIGINT); |
|
211 |
- sigdelset(&sigset, SIGTERM); |
|
212 |
- sigdelset(&sigset, SIGSEGV); |
|
213 |
- sigdelset(&sigset, SIGHUP); |
|
214 |
- sigprocmask(SIG_SETMASK, &sigset, NULL); |
|
215 |
- |
|
216 |
- /* SIGINT, SIGTERM, SIGSEGV */ |
|
217 |
- sigact.sa_handler = sighandler; |
|
218 |
- sigemptyset(&sigact.sa_mask); |
|
219 |
- sigaddset(&sigact.sa_mask, SIGINT); |
|
220 |
- sigaddset(&sigact.sa_mask, SIGTERM); |
|
221 |
- sigaddset(&sigact.sa_mask, SIGHUP); |
|
222 |
- sigaction(SIGINT, &sigact, NULL); |
|
223 |
- sigaction(SIGTERM, &sigact, NULL); |
|
224 |
-#ifndef CL_DEBUG |
|
225 |
- sigaction(SIGSEGV, &sigact, NULL); |
|
226 |
-#endif |
|
227 |
- sigaction(SIGHUP, &sigact, NULL); |
|
228 |
- |
|
229 |
- |
|
230 |
- while(1) { |
|
231 |
- |
|
232 |
- for(i = 0; ; i++) { /* find a free session */ |
|
233 |
- |
|
234 |
- /* free all finished childs */ |
|
235 |
- for(j = 0; j <= childs; j++) |
|
236 |
- if(session[j] && waitpid(session[j], &status, WNOHANG)) |
|
237 |
- session[j] = 0; |
|
238 |
- |
|
239 |
- if(i == childs) { |
|
240 |
- i = 0; |
|
241 |
- usleep(50000); |
|
242 |
- } |
|
243 |
- |
|
244 |
- if(!session[i]) |
|
245 |
- break; |
|
246 |
- } |
|
247 |
- |
|
248 |
- if((acceptd = accept(socketd, NULL, NULL)) == -1) { |
|
249 |
- logg("!accept() failed.\n"); |
|
250 |
- /* exit ? */ |
|
251 |
- continue; |
|
252 |
- } |
|
253 |
- |
|
254 |
- if((bread = read(acceptd, buff, 1024)) == -1) { |
|
255 |
- logg("!read(desc %d) failed.\n", acceptd); |
|
256 |
- } else { |
|
257 |
- |
|
258 |
- buff[bread] = 0; |
|
259 |
- chomp(buff); |
|
260 |
- |
|
261 |
- if(!strncmp(buff, CMD1, strlen(CMD1))) { /* SCAN */ |
|
262 |
- session[i] = procscan(buff + strlen(CMD1) + 1, root, &limits, options, copt, acceptd, 0); |
|
263 |
- |
|
264 |
- } else if(!strncmp(buff, CMD2, strlen(CMD2))) { /* RAWSCAN */ |
|
265 |
- options &= ~CL_ARCHIVE; |
|
266 |
- session[i] = procscan(buff + strlen(CMD2) + 1, root, NULL, options, copt, acceptd, 0); |
|
267 |
- |
|
268 |
- } else if(!strncmp(buff, CMD3, strlen(CMD3))) { /* QUIT */ |
|
269 |
- kill(0, SIGTERM); |
|
270 |
- |
|
271 |
- } else if(!strncmp(buff, CMD4, strlen(CMD4))) { /* RELOAD */ |
|
272 |
- mdprintf(acceptd, "RELOADING\n"); |
|
273 |
- |
|
274 |
- /* wait until all childs are finished */ |
|
275 |
- do { |
|
276 |
- need_wait = 0; |
|
277 |
- |
|
278 |
- /* free all finished childs */ |
|
279 |
- for(i = 0; i <= childs; i++) |
|
280 |
- if(session[i] && waitpid(session[i], &status, WNOHANG)) |
|
281 |
- session[i] = 0; |
|
282 |
- |
|
283 |
- for(i = 0; i <= childs; i++) |
|
284 |
- if(session[i]) |
|
285 |
- need_wait = 1; |
|
286 |
- |
|
287 |
- if(need_wait) |
|
288 |
- usleep(200000); |
|
289 |
- |
|
290 |
- } while(need_wait); |
|
291 |
- |
|
292 |
- cl_freetrie(root); |
|
293 |
- root = NULL; |
|
294 |
- logg("Reading databases from %s\n", dbdir); |
|
295 |
- //cl_statfree(&dbstat); |
|
296 |
- //cl_statinidir(dbdir, &dbstat); |
|
297 |
- virnum = 0; |
|
298 |
- if((ret = cl_loaddbdir(dbdir, &root, &virnum))) { |
|
299 |
- logg("!%s\n", cl_strerror(ret)); |
|
300 |
- exit(1); |
|
301 |
- } |
|
302 |
- |
|
303 |
- if(!root) { |
|
304 |
- logg("!Database initialization problem.\n"); |
|
305 |
- exit(1); |
|
306 |
- } else { |
|
307 |
- if((ret = cl_buildtrie(root)) != 0) { |
|
308 |
- logg("!Database initialization error: can't build the trie: %s\n", cl_strerror(i)); |
|
309 |
- exit(1); |
|
310 |
- } |
|
311 |
- /* check integrity */ |
|
312 |
- if(!testsignature(root)) { |
|
313 |
- logg("!Unable to detect test signature.\n"); |
|
314 |
- exit(1); |
|
315 |
- } |
|
316 |
- |
|
317 |
- logg("Database correctly reloaded (%d viruses)\n", virnum); |
|
318 |
- mdprintf(acceptd, "RELOADED\n"); |
|
319 |
- } |
|
320 |
- |
|
321 |
- } else if(!strncmp(buff, CMD5, strlen(CMD5))) { /* PING */ |
|
322 |
- mdprintf(acceptd, "PONG\n"); |
|
323 |
- |
|
324 |
- } else if(!strncmp(buff, CMD6, strlen(CMD6))) { /* CONTSCAN */ |
|
325 |
- session[i] = procscan(buff + strlen(CMD6) + 1, root, &limits, options, copt, acceptd, 1); |
|
326 |
- |
|
327 |
- } else if(!strncmp(buff, CMD7, strlen(CMD7))) { /* VERSION */ |
|
328 |
- mdprintf(acceptd, "clamd / ClamAV version "VERSION"\n"); |
|
329 |
- |
|
330 |
- } else if(!strncmp(buff, CMD8, strlen(CMD8))) { /* STREAM */ |
|
331 |
- session[i] = procscan(NULL, root, &limits, options, copt, acceptd, 0); |
|
332 |
- } |
|
333 |
- } |
|
334 |
- |
|
335 |
- close(acceptd); |
|
336 |
- } |
|
337 |
-} |
|
338 |
- |
|
339 |
-void sighandler(int sig) |
|
340 |
-{ |
|
341 |
- time_t currtime; |
|
342 |
- |
|
343 |
- switch(sig) { |
|
344 |
- case SIGINT: |
|
345 |
- case SIGTERM: |
|
346 |
- time(&currtime); |
|
347 |
- logg("--- Process %d stopped at %s", getpid(), ctime(&currtime)); |
|
348 |
- exit(0); |
|
349 |
- break; /* not reached */ |
|
350 |
- |
|
351 |
-#ifndef CL_DEBUG |
|
352 |
- case SIGSEGV: |
|
353 |
- logg("Segmentation fault :-( Bye..\n"); |
|
354 |
- exit(11); /* probably not reached at all */ |
|
355 |
- break; /* not reached */ |
|
356 |
-#endif |
|
357 |
- case SIGHUP: |
|
358 |
- sighup = 1; |
|
359 |
- logg("SIGHUP catched: log file re-opened.\n"); |
|
360 |
- break; |
|
361 |
- case SIGALRM: |
|
362 |
- if(acceptd > 0) |
|
363 |
- mdprintf(acceptd, "Session (PID %d): Time out ERROR\n", getpid()); |
|
364 |
- logg("Session (PID %d) stopped due to timeout.\n", getpid()); |
|
365 |
- exit(0); |
|
366 |
- } |
|
367 |
-} |
... | ... |
@@ -187,7 +187,9 @@ int acceptloop_th(int socketd, struct cl_node *root, const struct cfgstruct *cop |
187 | 187 |
sigset_t sigset; |
188 | 188 |
client_conn_t *client_conn; |
189 | 189 |
struct cfgstruct *cpt; |
190 |
- /* char *buff[BUFFSIZE+1]; */ |
|
190 |
+#ifdef HAVE_STRERROR_R |
|
191 |
+ char buff[BUFFSIZE + 1]; |
|
192 |
+#endif |
|
191 | 193 |
unsigned int selfchk; |
192 | 194 |
time_t start_time, current_time; |
193 | 195 |
pid_t mainpid; |
... | ... |
@@ -398,9 +400,12 @@ int acceptloop_th(int socketd, struct cl_node *root, const struct cfgstruct *cop |
398 | 398 |
for(;;) { |
399 | 399 |
new_sd = accept(socketd, NULL, NULL); |
400 | 400 |
if((new_sd == -1) && (errno != EINTR)) { |
401 |
- logg("!accept() failed\n"); |
|
402 |
- /* logg("!accept() failed: %s", strerror_r(errno, buff, BUFFSIZE)); */ |
|
403 | 401 |
/* very bad - need to exit or restart */ |
402 |
+#ifdef HAVE_STRERROR_R |
|
403 |
+ logg("!accept() failed: %s", strerror_r(errno, buff, BUFFSIZE)); |
|
404 |
+#else |
|
405 |
+ logg("!accept() failed\n"); |
|
406 |
+#endif |
|
404 | 407 |
continue; |
405 | 408 |
} |
406 | 409 |
|
... | ... |
@@ -8227,7 +8227,11 @@ _ACEOF |
8227 | 8227 |
|
8228 | 8228 |
|
8229 | 8229 |
|
8230 |
-for ac_func in poll |
|
8230 |
+ |
|
8231 |
+ |
|
8232 |
+ |
|
8233 |
+ |
|
8234 |
+for ac_func in poll setsid memcpy snprintf strerror_r |
|
8231 | 8235 |
do |
8232 | 8236 |
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` |
8233 | 8237 |
echo "$as_me:$LINENO: checking for $ac_func" >&5 |
... | ... |
@@ -8715,84 +8719,6 @@ if test "${enable_clamuko+set}" = set; then |
8715 | 8715 |
want_clamuko="no" |
8716 | 8716 |
fi; |
8717 | 8717 |
|
8718 |
- |
|
8719 |
- |
|
8720 |
- |
|
8721 |
-for ac_func in setsid memcpy snprintf |
|
8722 |
-do |
|
8723 |
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` |
|
8724 |
-echo "$as_me:$LINENO: checking for $ac_func" >&5 |
|
8725 |
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 |
|
8726 |
-if eval "test \"\${$as_ac_var+set}\" = set"; then |
|
8727 |
- echo $ECHO_N "(cached) $ECHO_C" >&6 |
|
8728 |
-else |
|
8729 |
- cat >conftest.$ac_ext <<_ACEOF |
|
8730 |
-#line $LINENO "configure" |
|
8731 |
-#include "confdefs.h" |
|
8732 |
-/* System header to define __stub macros and hopefully few prototypes, |
|
8733 |
- which can conflict with char $ac_func (); below. */ |
|
8734 |
-#include <assert.h> |
|
8735 |
-/* Override any gcc2 internal prototype to avoid an error. */ |
|
8736 |
-#ifdef __cplusplus |
|
8737 |
-extern "C" |
|
8738 |
-#endif |
|
8739 |
-/* We use char because int might match the return type of a gcc2 |
|
8740 |
- builtin and then its argument prototype would still apply. */ |
|
8741 |
-char $ac_func (); |
|
8742 |
-char (*f) (); |
|
8743 |
- |
|
8744 |
-#ifdef F77_DUMMY_MAIN |
|
8745 |
-# ifdef __cplusplus |
|
8746 |
- extern "C" |
|
8747 |
-# endif |
|
8748 |
- int F77_DUMMY_MAIN() { return 1; } |
|
8749 |
-#endif |
|
8750 |
-int |
|
8751 |
-main () |
|
8752 |
-{ |
|
8753 |
-/* The GNU C library defines this for functions which it implements |
|
8754 |
- to always fail with ENOSYS. Some functions are actually named |
|
8755 |
- something starting with __ and the normal name is an alias. */ |
|
8756 |
-#if defined (__stub_$ac_func) || defined (__stub___$ac_func) |
|
8757 |
-choke me |
|
8758 |
-#else |
|
8759 |
-f = $ac_func; |
|
8760 |
-#endif |
|
8761 |
- |
|
8762 |
- ; |
|
8763 |
- return 0; |
|
8764 |
-} |
|
8765 |
-_ACEOF |
|
8766 |
-rm -f conftest.$ac_objext conftest$ac_exeext |
|
8767 |
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 |
|
8768 |
- (eval $ac_link) 2>&5 |
|
8769 |
- ac_status=$? |
|
8770 |
- echo "$as_me:$LINENO: \$? = $ac_status" >&5 |
|
8771 |
- (exit $ac_status); } && |
|
8772 |
- { ac_try='test -s conftest$ac_exeext' |
|
8773 |
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 |
|
8774 |
- (eval $ac_try) 2>&5 |
|
8775 |
- ac_status=$? |
|
8776 |
- echo "$as_me:$LINENO: \$? = $ac_status" >&5 |
|
8777 |
- (exit $ac_status); }; }; then |
|
8778 |
- eval "$as_ac_var=yes" |
|
8779 |
-else |
|
8780 |
- echo "$as_me: failed program was:" >&5 |
|
8781 |
-cat conftest.$ac_ext >&5 |
|
8782 |
-eval "$as_ac_var=no" |
|
8783 |
-fi |
|
8784 |
-rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext |
|
8785 |
-fi |
|
8786 |
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 |
|
8787 |
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 |
|
8788 |
-if test `eval echo '${'$as_ac_var'}'` = yes; then |
|
8789 |
- cat >>confdefs.h <<_ACEOF |
|
8790 |
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 |
|
8791 |
-_ACEOF |
|
8792 |
- |
|
8793 |
-fi |
|
8794 |
-done |
|
8795 |
- |
|
8796 | 8718 |
echo "$as_me:$LINENO: checking whether setpgrp takes no argument" >&5 |
8797 | 8719 |
echo $ECHO_N "checking whether setpgrp takes no argument... $ECHO_C" >&6 |
8798 | 8720 |
if test "${ac_cv_func_setpgrp_void+set}" = set; then |
... | ... |
@@ -57,7 +57,7 @@ AC_TYPE_OFF_T |
57 | 57 |
AC_COMPILE_CHECK_SIZEOF(short) |
58 | 58 |
AC_COMPILE_CHECK_SIZEOF(int) |
59 | 59 |
AC_COMPILE_CHECK_SIZEOF(long) |
60 |
-AC_CHECK_FUNCS(poll) |
|
60 |
+AC_CHECK_FUNCS(poll setsid memcpy snprintf strerror_r) |
|
61 | 61 |
|
62 | 62 |
have_pthreads=no |
63 | 63 |
AC_CHECK_HEADER(pthread.h,[have_pthreads=yes],) |
... | ... |
@@ -80,7 +80,6 @@ AC_ARG_ENABLE(clamuko, |
80 | 80 |
[ --disable-clamuko Disable clamuko support (Linux and FreeBSD only)], |
81 | 81 |
want_clamuko="no",) |
82 | 82 |
|
83 |
-AC_CHECK_FUNCS(setsid memcpy snprintf) |
|
84 | 83 |
AC_FUNC_SETPGRP |
85 | 84 |
|
86 | 85 |
have_milter="no" |
... | ... |
@@ -298,76 +298,73 @@ struct Decode |
298 | 298 |
}; |
299 | 299 |
|
300 | 300 |
|
301 |
-struct MarkHeader MarkHead; |
|
302 |
-struct NewMainArchiveHeader NewMhd; |
|
303 |
-struct NewFileHeader NewLhd; |
|
304 |
-struct BlockHeader BlockHead; |
|
301 |
+static struct MarkHeader MarkHead; |
|
302 |
+static struct NewMainArchiveHeader NewMhd; |
|
303 |
+static struct NewFileHeader NewLhd; |
|
304 |
+static struct BlockHeader BlockHead; |
|
305 | 305 |
|
306 |
-UBYTE *TempMemory; /* temporary unpack-buffer */ |
|
307 |
-char *CommMemory; |
|
306 |
+static UBYTE *TempMemory; /* temporary unpack-buffer */ |
|
307 |
+static char *CommMemory; |
|
308 | 308 |
|
309 | 309 |
|
310 |
-UBYTE *UnpMemory; |
|
311 |
-char ArgName[NM]; /* current file in rar archive */ |
|
312 |
-char ArcFileName[NM]; /* file to decompress */ |
|
310 |
+static UBYTE *UnpMemory; |
|
311 |
+static char ArgName[NM]; /* current file in rar archive */ |
|
312 |
+static char ArcFileName[NM]; /* file to decompress */ |
|
313 | 313 |
|
314 | 314 |
#ifdef _USE_MEMORY_TO_MEMORY_DECOMPRESSION /* mem-to-mem decompression */ |
315 |
- MemoryFile *MemRARFile; /* pointer to RAR file in memory*/ |
|
315 |
+static MemoryFile *MemRARFile; /* pointer to RAR file in memory*/ |
|
316 | 316 |
#else |
317 |
- FILE *ArcPtr; /* input RAR file handler */ |
|
317 |
+static FILE *ArcPtr; /* input RAR file handler */ |
|
318 | 318 |
#endif |
319 |
-char Password[255]; /* password to decrypt files */ |
|
319 |
+static char Password[255]; /* password to decrypt files */ |
|
320 | 320 |
|
321 |
-unsigned char *temp_output_buffer; /* extract files to this pointer*/ |
|
322 |
-unsigned long *temp_output_buffer_offset; /* size of temp. extract buffer */ |
|
321 |
+static unsigned char *temp_output_buffer; /* extract files to this pointer*/ |
|
322 |
+static unsigned long *temp_output_buffer_offset; /* size of temp. extract buffer */ |
|
323 | 323 |
|
324 |
-int MainHeadSize; |
|
324 |
+static int MainHeadSize; |
|
325 | 325 |
|
326 |
-long CurBlockPos,NextBlockPos; |
|
326 |
+static long CurBlockPos,NextBlockPos; |
|
327 | 327 |
|
328 |
-unsigned long CurUnpRead, CurUnpWrite; |
|
329 |
-long UnpPackedSize; |
|
330 |
-long DestUnpSize; |
|
328 |
+static unsigned long CurUnpRead, CurUnpWrite; |
|
329 |
+static long UnpPackedSize; |
|
330 |
+static long DestUnpSize; |
|
331 | 331 |
|
332 |
-UDWORD HeaderCRC; |
|
333 |
-int Encryption; |
|
332 |
+static UDWORD HeaderCRC; |
|
333 |
+static int Encryption; |
|
334 | 334 |
|
335 |
-unsigned int UnpWrSize; |
|
336 |
-unsigned char *UnpWrAddr; |
|
337 |
-unsigned int UnpPtr,WrPtr; |
|
335 |
+static unsigned int UnpPtr,WrPtr; |
|
338 | 336 |
|
339 |
-unsigned char PN1,PN2,PN3; |
|
340 |
-unsigned short OldKey[4]; |
|
337 |
+static unsigned char PN1,PN2,PN3; |
|
338 |
+static unsigned short OldKey[4]; |
|
341 | 339 |
|
342 | 340 |
|
343 | 341 |
|
344 | 342 |
/* function header definitions */ |
345 |
-int ReadHeader(int BlockType); |
|
346 |
-BOOL ExtrFile(int desc); |
|
347 |
-BOOL ListFile(void); |
|
348 |
-int tread(void *stream,void *buf,unsigned len); |
|
349 |
-int tseek(void *stream,long offset,int fromwhere); |
|
350 |
-BOOL UnstoreFile(void); |
|
351 |
-int IsArchive(void); |
|
352 |
-int ReadBlock(int BlockType); |
|
353 |
-unsigned int UnpRead(unsigned char *Addr,unsigned int Count); |
|
354 |
-void UnpInitData(void); |
|
355 |
-void Unpack(unsigned char *UnpAddr, BOOL FileFound); |
|
356 |
-UBYTE DecodeAudio(int Delta); |
|
343 |
+static int ReadHeader(int BlockType); |
|
344 |
+static BOOL ExtrFile(int desc); |
|
345 |
+static int tread(void *stream,void *buf,unsigned len); |
|
346 |
+static int tseek(void *stream,long offset,int fromwhere); |
|
347 |
+static BOOL UnstoreFile(void); |
|
348 |
+static int IsArchive(void); |
|
349 |
+static int ReadBlock(int BlockType); |
|
350 |
+static unsigned int UnpRead(unsigned char *Addr,unsigned int Count); |
|
351 |
+static void UnpInitData(void); |
|
352 |
+static void Unpack(unsigned char *UnpAddr, BOOL FileFound); |
|
353 |
+static UBYTE DecodeAudio(int Delta); |
|
357 | 354 |
static void DecodeNumber(struct Decode *Dec); |
358 |
-void UpdKeys(UBYTE *Buf); |
|
359 |
-void SetCryptKeys(char *Password); |
|
360 |
-void SetOldKeys(char *Password); |
|
361 |
-void DecryptBlock(unsigned char *Buf); |
|
362 |
-void InitCRC(void); |
|
363 |
-UDWORD CalcCRC32(UDWORD StartCRC,UBYTE *Addr,UDWORD Size); |
|
364 |
-void UnpReadBuf(int FirstBuf); |
|
365 |
-void ReadTables(void); |
|
355 |
+static void UpdKeys(UBYTE *Buf); |
|
356 |
+static void SetCryptKeys(char* NewPassword); |
|
357 |
+static void SetOldKeys(char *NewPassword); |
|
358 |
+static void DecryptBlock(unsigned char *Buf); |
|
359 |
+static void InitCRC(void); |
|
360 |
+static UDWORD CalcCRC32(UDWORD StartCRC,UBYTE *Addr,UDWORD Size); |
|
361 |
+static void UnpReadBuf(int FirstBuf); |
|
362 |
+static void ReadTables(void); |
|
366 | 363 |
static void ReadLastTables(void); |
367 | 364 |
static void MakeDecodeTables(unsigned char *LenTab, |
368 | 365 |
struct Decode *Dec, |
369 | 366 |
int Size); |
370 |
-int stricomp(char *Str1,char *Str2); |
|
367 |
+static int stricomp(char *Str1,char *Str2); |
|
371 | 368 |
/* ------------------------------------------------------------------------ */ |
372 | 369 |
|
373 | 370 |
|
... | ... |
@@ -1151,7 +1148,7 @@ int tseek(void *stream,long offset,int fromwhere) |
1151 | 1151 |
#endif |
1152 | 1152 |
|
1153 | 1153 |
|
1154 |
-char* strupper(char *Str) |
|
1154 |
+static char* strupper(char *Str) |
|
1155 | 1155 |
{ |
1156 | 1156 |
char *ChPtr; |
1157 | 1157 |
for (ChPtr=Str;*ChPtr;ChPtr++) |
... | ... |
@@ -1282,7 +1279,7 @@ struct AudioVariables |
1282 | 1282 |
#define MC 257 |
1283 | 1283 |
|
1284 | 1284 |
|
1285 |
-struct AudioVariables AudV[4]; |
|
1285 |
+static struct AudioVariables AudV[4]; |
|
1286 | 1286 |
|
1287 | 1287 |
#define GetBits() \ |
1288 | 1288 |
BitField = ( ( ( (UDWORD)InBuf[InAddr] << 16 ) | \ |
... | ... |
@@ -1299,19 +1296,19 @@ static unsigned char *UnpBuf; |
1299 | 1299 |
static unsigned int BitField; |
1300 | 1300 |
static unsigned int Number; |
1301 | 1301 |
|
1302 |
-unsigned char InBuf[8192]; /* input read buffer */ |
|
1302 |
+static unsigned char InBuf[8192]; /* input read buffer */ |
|
1303 | 1303 |
|
1304 |
-unsigned char UnpOldTable[MC*4]; |
|
1304 |
+static unsigned char UnpOldTable[MC*4]; |
|
1305 | 1305 |
|
1306 |
-unsigned int InAddr,InBit,ReadTop; |
|
1306 |
+static unsigned int InAddr,InBit,ReadTop; |
|
1307 | 1307 |
|
1308 |
-unsigned int LastDist,LastLength; |
|
1308 |
+static unsigned int LastDist,LastLength; |
|
1309 | 1309 |
static unsigned int Length,Distance; |
1310 | 1310 |
|
1311 |
-unsigned int OldDist[4],OldDistPtr; |
|
1311 |
+static unsigned int OldDist[4],OldDistPtr; |
|
1312 | 1312 |
|
1313 | 1313 |
|
1314 |
-struct LitDecode |
|
1314 |
+static struct LitDecode |
|
1315 | 1315 |
{ |
1316 | 1316 |
unsigned int MaxNum; |
1317 | 1317 |
unsigned int DecodeLen[16]; |
... | ... |
@@ -1319,7 +1316,7 @@ struct LitDecode |
1319 | 1319 |
unsigned int DecodeNum[NC]; |
1320 | 1320 |
} LD; |
1321 | 1321 |
|
1322 |
-struct DistDecode |
|
1322 |
+static struct DistDecode |
|
1323 | 1323 |
{ |
1324 | 1324 |
unsigned int MaxNum; |
1325 | 1325 |
unsigned int DecodeLen[16]; |
... | ... |
@@ -1327,7 +1324,7 @@ struct DistDecode |
1327 | 1327 |
unsigned int DecodeNum[DC]; |
1328 | 1328 |
} DD; |
1329 | 1329 |
|
1330 |
-struct RepDecode |
|
1330 |
+static struct RepDecode |
|
1331 | 1331 |
{ |
1332 | 1332 |
unsigned int MaxNum; |
1333 | 1333 |
unsigned int DecodeLen[16]; |
... | ... |
@@ -1335,7 +1332,7 @@ struct RepDecode |
1335 | 1335 |
unsigned int DecodeNum[RC]; |
1336 | 1336 |
} RD; |
1337 | 1337 |
|
1338 |
-struct MultDecode |
|
1338 |
+static struct MultDecode |
|
1339 | 1339 |
{ |
1340 | 1340 |
unsigned int MaxNum; |
1341 | 1341 |
unsigned int DecodeLen[16]; |
... | ... |
@@ -1343,7 +1340,7 @@ struct MultDecode |
1343 | 1343 |
unsigned int DecodeNum[MC]; |
1344 | 1344 |
} MD[4]; |
1345 | 1345 |
|
1346 |
-struct BitDecode |
|
1346 |
+static struct BitDecode |
|
1347 | 1347 |
{ |
1348 | 1348 |
unsigned int MaxNum; |
1349 | 1349 |
unsigned int DecodeLen[16]; |
... | ... |
@@ -1353,7 +1350,7 @@ struct BitDecode |
1353 | 1353 |
|
1354 | 1354 |
static struct MultDecode *MDPtr[4]={&MD[0],&MD[1],&MD[2],&MD[3]}; |
1355 | 1355 |
|
1356 |
-int UnpAudioBlock,UnpChannels,CurChannel,ChannelDelta; |
|
1356 |
+static int UnpAudioBlock,UnpChannels,CurChannel,ChannelDelta; |
|
1357 | 1357 |
|
1358 | 1358 |
|
1359 | 1359 |
void Unpack(unsigned char *UnpAddr, BOOL FileFound) |
... | ... |
@@ -2345,10 +2342,10 @@ UBYTE DecodeAudio(int Delta) |
2345 | 2345 |
((UDWORD)SubstTable[(int)(t>>24)&255]<<24) ) |
2346 | 2346 |
|
2347 | 2347 |
|
2348 |
-UDWORD CRCTab[256]; |
|
2348 |
+static UDWORD CRCTab[256]; |
|
2349 | 2349 |
|
2350 |
-UBYTE SubstTable[256]; |
|
2351 |
-UBYTE InitSubstTable[256]={ |
|
2350 |
+static UBYTE SubstTable[256]; |
|
2351 |
+static const UBYTE InitSubstTable[256]={ |
|
2352 | 2352 |
215, 19,149, 35, 73,197,192,205,249, 28, 16,119, 48,221, 2, 42, |
2353 | 2353 |
232, 1,177,233, 14, 88,219, 25,223,195,244, 90, 87,239,153,137, |
2354 | 2354 |
255,199,147, 70, 92, 66,246, 13,216, 40, 62, 29,217,230, 86, 6, |
... | ... |
@@ -2367,10 +2364,10 @@ UBYTE InitSubstTable[256]={ |
2367 | 2367 |
116,184,160, 96,109, 37, 30,106,140,104,150, 5,204,117,112, 84 |
2368 | 2368 |
}; |
2369 | 2369 |
|
2370 |
-UDWORD Key[4]; |
|
2370 |
+static UDWORD Key[4]; |
|
2371 | 2371 |
|
2372 | 2372 |
|
2373 |
-void EncryptBlock(UBYTE *Buf) |
|
2373 |
+static void EncryptBlock(UBYTE *Buf) |
|
2374 | 2374 |
{ |
2375 | 2375 |
int I; |
2376 | 2376 |
|
... | ... |
@@ -2511,7 +2508,7 @@ void UpdKeys(UBYTE *Buf) |
2511 | 2511 |
} |
2512 | 2512 |
} |
2513 | 2513 |
|
2514 |
-void SetCryptKeys(char *Password) |
|
2514 |
+static void SetCryptKeys(char *NewPassword) |
|
2515 | 2515 |
{ |
2516 | 2516 |
unsigned int I,J,K,PswLength; |
2517 | 2517 |
unsigned char N1,N2; |
... | ... |
@@ -2521,15 +2518,15 @@ void SetCryptKeys(char *Password) |
2521 | 2521 |
UBYTE Ch; |
2522 | 2522 |
#endif |
2523 | 2523 |
|
2524 |
- SetOldKeys(Password); |
|
2524 |
+ SetOldKeys(NewPassword); |
|
2525 | 2525 |
|
2526 | 2526 |
Key[0]=0xD3A3B879L; |
2527 | 2527 |
Key[1]=0x3F6D12F7L; |
2528 | 2528 |
Key[2]=0x7515A235L; |
2529 | 2529 |
Key[3]=0xA4E7F123L; |
2530 | 2530 |
memset(Psw,0,sizeof(Psw)); |
2531 |
- strcpy((char *)Psw,Password); |
|
2532 |
- PswLength=strlen(Password); |
|
2531 |
+ strcpy((char *)Psw,NewPassword); |
|
2532 |
+ PswLength=strlen(NewPassword); |
|
2533 | 2533 |
memcpy(SubstTable,InitSubstTable,sizeof(SubstTable)); |
2534 | 2534 |
|
2535 | 2535 |
for (J=0;J<256;J++) |
... | ... |
@@ -2603,16 +2600,16 @@ void SetCryptKeys(char *Password) |
2603 | 2603 |
} |
2604 | 2604 |
|
2605 | 2605 |
|
2606 |
-void SetOldKeys(char *Password) |
|
2606 |
+void SetOldKeys(char *NewPassword) |
|
2607 | 2607 |
{ |
2608 | 2608 |
UDWORD PswCRC; |
2609 | 2609 |
UBYTE Ch; |
2610 |
- PswCRC=CalcCRC32(0xFFFFFFFFL,(UBYTE*)Password,strlen(Password)); |
|
2610 |
+ PswCRC=CalcCRC32(0xFFFFFFFFL,(UBYTE*)NewPassword,strlen(NewPassword)); |
|
2611 | 2611 |
OldKey[0]=(UWORD)PswCRC; |
2612 | 2612 |
OldKey[1]=(UWORD)(PswCRC>>16); |
2613 | 2613 |
OldKey[2]=OldKey[3]=0; |
2614 | 2614 |
PN1=PN2=PN3=0; |
2615 |
- while ((Ch=*Password)!=0) |
|
2615 |
+ while ((Ch=*NewPassword)!=0) |
|
2616 | 2616 |
{ |
2617 | 2617 |
PN1+=Ch; |
2618 | 2618 |
PN2^=Ch; |
... | ... |
@@ -2620,7 +2617,7 @@ void SetOldKeys(char *Password) |
2620 | 2620 |
PN3=(UBYTE)rol(PN3,1); |
2621 | 2621 |
OldKey[2]^=((UWORD)(Ch^CRCTab[Ch])); |
2622 | 2622 |
OldKey[3]+=((UWORD)(Ch+(CRCTab[Ch]>>16))); |
2623 |
- Password++; |
|
2623 |
+ NewPassword++; |
|
2624 | 2624 |
} |
2625 | 2625 |
} |
2626 | 2626 |
|
... | ... |
@@ -2642,7 +2639,7 @@ void InitCRC(void) |
2642 | 2642 |
} |
2643 | 2643 |
|
2644 | 2644 |
|
2645 |
-UDWORD CalcCRC32(UDWORD StartCRC,UBYTE *Addr,UDWORD Size) |
|
2645 |
+static UDWORD CalcCRC32(UDWORD StartCRC,UBYTE *Addr,UDWORD Size) |
|
2646 | 2646 |
{ |
2647 | 2647 |
unsigned int I; |
2648 | 2648 |
for (I=0; I<Size; I++) |