git-svn: trunk@105
Tomasz Kojm authored on 2003/11/09 11:29:23... | ... |
@@ -1,52 +1,60 @@ |
1 |
-Tomasz Kojm <zolw@konarski.edu.pl> |
|
1 |
+Tomasz Kojm <tkojm*clamav.net> |
|
2 | 2 |
home page : http://www.konarski.edu.pl/~zolw |
3 |
-gpg key : http://www.konarski.edu.pl/~zolw/tkojm.gpg |
|
3 |
+gpg key : http://www.clamav.net/gpg/tkojm.gpg |
|
4 | 4 |
GPG = 0DCA 5A08 407D 5288 279D B434 5482 2DC8 985A 444B |
5 | 5 |
|
6 |
-Nigel Horne <njh@bandsman.co.uk> |
|
6 |
+Nigel Horne <njh*clamav.net> |
|
7 | 7 |
home page : http://bandsman.co.uk |
8 | 8 |
Author of clamav-milter and the whole mbox code. |
9 | 9 |
|
10 | 10 |
System administrator (www, mailing lists, mirror issues, virus |
11 |
-submission mechanisms): Luca 'NERvOus' Gibelli <nervous@nervous.it> |
|
11 |
+submission mechanisms): Luca 'NERvOus' Gibelli <nervous*clamav.net> |
|
12 |
+ |
|
13 |
+Submission management interface (for database developers only): Thomas Madsen |
|
14 |
+<tm*softcom.dk> |
|
15 |
+ |
|
12 | 16 |
|
13 | 17 |
Database developers: |
14 | 18 |
|
15 |
-aCaB <acab@digitalfuture.it> |
|
16 |
-Diego D'Ambra <da@softcom.dk> |
|
17 |
-Jason Englander <jason@englanders.cc> |
|
18 |
-Tomasz Kojm <zolw@konarski.edu.pl> |
|
19 |
-Tomasz Papszun <tomek@lodz.tpsa.pl> |
|
19 |
+aCaB <acab*clamav.net> |
|
20 |
+Diego D'Ambra <diego*clamav.net> |
|
21 |
+Jason Englander <jason*clamav.net> |
|
22 |
+Tomasz Kojm <tkojm*clamav.net> |
|
23 |
+Tomasz Papszun <tomek*clamav.net> |
|
20 | 24 |
|
25 |
+ClamAV logo: Mia Kalenius and Sergei Pronin <sp*finndesign.fi> |
|
26 |
+TrashScan was written by Trashware <trashware*gmx.net>. |
|
21 | 27 |
|
22 |
-TrashScan was written by Trashware <trashware@gmx.net>. |
|
28 |
+libclamav/zziplib: Guido Draheim <guidod*gmx.de> |
|
29 |
+libclamav/unrarlib.c: Christian Scheurer and Johannes Winkelmann (jw*tks6.net) |
|
23 | 30 |
|
24 | 31 |
ClamAV patches were submitted by (in alphabetical order): |
25 | 32 |
|
26 |
-Kamil Andrusz <wizz@mniam.net> |
|
27 |
-Patrick Bihan-Faou <patrick@mindstep.com> |
|
28 |
-Damien Curtain <damien@pagefault.org> |
|
29 |
-Michael Dankov <misha@btrc.ru> |
|
30 |
-Alejandro Dubrovsky <s328940@student.uq.edu.au> |
|
31 |
-Magnus Ekdahl <magnus@debian.org> |
|
32 |
-Jason Englander <jason@englanders.cc> |
|
33 |
-David Ford <david+cert@blue-labs.org> |
|
34 |
-Nigel Horne <njh@smsltd.demon.co.uk> |
|
35 |
-Hrvoje Habjanic <hrvoje.habjanic@zg.hinet.hr> |
|
36 |
-Nicholas M. Kirsch <nick@kirsch.org> |
|
37 |
-Robbert Kouprie <robbert@exx.nl> |
|
38 |
-Thomas Lamy <Thomas.Lamy@in-online.net> |
|
39 |
-Peter N Lewis <peter@stairways.com.au> |
|
40 |
-Mark Mielke <mark@mark.mielke.cc> |
|
41 |
-Arkadiusz Miskiewicz <misiek@pld.org.pl> |
|
42 |
-Hendrik Muhs <Hendrik.Muhs@student.uni-magdeburg.de> |
|
43 |
-Masaki Ogawa <proc@mac.com> |
|
44 |
-Ed Phillips <ed@UDel.Edu> |
|
45 |
-Andreas Piesk <Andreas.Piesk@heise.de> |
|
46 |
-Ant La Porte <ant@dvere.net> |
|
47 |
-Thomas Quinot <thomas@cuivre.fr.eu.org> |
|
48 |
-Joe Talbott <josepht@cstone.net> |
|
49 |
-Gernot Tenchio <g.tenchio@telco-tech.de> |
|
50 |
-Laurent Wacrenier <lwa@teaser.fr> |
|
51 |
-David Woakes <david@mitredata.co.uk> |
|
52 |
-Andoni Zubimendi <andoni@lpsat.net> |
|
33 |
+Kamil Andrusz <wizz*mniam.net> |
|
34 |
+Patrick Bihan-Faou <patrick*mindstep.com> |
|
35 |
+Damien Curtain <damien*pagefault.org> |
|
36 |
+Michael Dankov <misha*btrc.ru> |
|
37 |
+Alejandro Dubrovsky <s328940*student.uq.edu.au> |
|
38 |
+Magnus Ekdahl <magnus*debian.org> |
|
39 |
+Jason Englander <jason*englanders.cc> |
|
40 |
+David Ford <david+cert*blue-labs.org> |
|
41 |
+Nigel Horne <njh*smsltd.demon.co.uk> |
|
42 |
+Hrvoje Habjanic <hrvoje.habjanic*zg.hinet.hr> |
|
43 |
+Nicholas M. Kirsch <nick*kirsch.org> |
|
44 |
+Robbert Kouprie <robbert*exx.nl> |
|
45 |
+Thomas Lamy <Thomas.Lamy*in-online.net> |
|
46 |
+Peter N Lewis <peter*stairways.com.au> |
|
47 |
+Mark Mielke <mark*mark.mielke.cc> |
|
48 |
+Arkadiusz Miskiewicz <misiek*pld.org.pl> |
|
49 |
+Hendrik Muhs <Hendrik.Muhs*student.uni-magdeburg.de> |
|
50 |
+Masaki Ogawa <proc*mac.com> |
|
51 |
+Ed Phillips <ed*UDel.Edu> |
|
52 |
+Andreas Piesk <Andreas.Piesk*heise.de> |
|
53 |
+Ant La Porte <ant*dvere.net> |
|
54 |
+Thomas Quinot <thomas*cuivre.fr.eu.org> |
|
55 |
+Matt Sullivan <matt*sullivan.gen.nz> |
|
56 |
+Joe Talbott <josepht*cstone.net> |
|
57 |
+Gernot Tenchio <g.tenchio*telco-tech.de> |
|
58 |
+Laurent Wacrenier <lwa*teaser.fr> |
|
59 |
+David Woakes <david*mitredata.co.uk> |
|
60 |
+Andoni Zubimendi <andoni*lpsat.net> |
... | ... |
@@ -1,5 +1,16 @@ |
1 |
+Sun Nov 9 03:21:48 CET 2003 (tk) |
|
2 |
+--------------------------------- |
|
3 |
+ * libclamav: archive wrapper and database parsing functions were using a |
|
4 |
+ huge buffers of size BUFFSIZE instead of FBUFFSIZE. These |
|
5 |
+ defines have been renamed to SCANBUFF and FILEBUFF respectively. |
|
6 |
+ The bug was responsible (e.g.) for clamd lockups (due to a stack |
|
7 |
+ size overflow) with CVD under FreeBSD (reported by Tim Wilde |
|
8 |
+ twilde*dyndns.org). The fix also makes all that buffers |
|
9 |
+ dynamically allocable (this is a part of Rudolph Pereira's |
|
10 |
+ patch that will be included soon). |
|
11 |
+ |
|
1 | 12 |
Thu Nov 6 22:40:58 CET 2003 (tk) |
13 |
+--------------------------------- |
|
2 | 14 |
* libclamav: zziplib: reverted to 0.12.83 |
3 | 15 |
|
4 | 16 |
Thu Nov 6 10:36:57 IST 2003 (njh) |
... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
Note: This README/NEWS file refers to the source tarball. Some things described |
2 |
-here may not be available in the binary packages. |
|
2 |
+here may not be available in a binary packages. |
|
3 | 3 |
-- |
4 | 4 |
|
5 | 5 |
|
... | ... |
@@ -8,7 +8,7 @@ here may not be available in the binary packages. |
8 | 8 |
---- |
9 | 9 |
|
10 | 10 |
-) clamd: |
11 |
- + fixed a race condition in the database reloading code (random hangs |
|
11 |
+ + fixed a race condition in database reloading code (random hangs |
|
12 | 12 |
under high load) |
13 | 13 |
+ fixed PidFile permissions (Magnus Ekdahl, bug reported by Tomasz Papszun) |
14 | 14 |
+ fixed LogFile permissions (Magnus Ekdahl) |
... | ... |
@@ -19,17 +19,15 @@ here may not be available in the binary packages. |
19 | 19 |
+ new directive Debug |
20 | 20 |
|
21 | 21 |
-) clamav-milter: |
22 |
- + |
|
23 | 22 |
+ new --force-scan flag |
24 | 23 |
+ new -P and -q flags by Nicholas M. Kirsch |
25 | 24 |
|
26 | 25 |
-) libclamav: |
27 | 26 |
+ multiple mbox fixes (thanks to Rene Bellora, Bernd Kuhls, Thomas Lamy, |
28 |
- Tomasz Papszun, |
|
29 |
- |
|
27 |
+ Tomasz Papszun) |
|
30 | 28 |
+ memory leak fixes (Thomas Lamy) |
31 |
- + support for a new database container format (CVD) with support for |
|
32 |
- digital signatures, |
|
29 |
+ + support for a new database container format (CVD) - compressed and |
|
30 |
+ digitally signed |
|
33 | 31 |
+ new scan option CL_DISABLERAR (disables built-in RAR unpacker) |
34 | 32 |
|
35 | 33 |
-) freshclam: |
... | ... |
@@ -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.11 2003/11/06 02:03:35 kojm Exp $ |
|
84 |
+dnl @version: $Id: aclocal.m4,v 1.12 2003/11/09 02:29:23 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.11 2003/11/06 02:03:35 kojm Exp $ |
|
4044 |
+dnl @version $Id: aclocal.m4,v 1.12 2003/11/09 02:29:23 kojm Exp $ |
|
4045 | 4045 |
dnl |
4046 | 4046 |
AC_DEFUN([AC_COMPILE_CHECK_SIZEOF], |
4047 | 4047 |
[changequote(<<, >>)dnl |
... | ... |
@@ -100,7 +100,7 @@ int dirscan(const char *dirname, char **virname, unsigned long int *scanned, con |
100 | 100 |
ret = 2; |
101 | 101 |
} else if(scanret != CL_CLEAN) { |
102 | 102 |
mdprintf(odesc, "%s: %s ERROR\n", fname, cl_strerror(scanret)); |
103 |
- logg("*%s: %s\n ERROR", fname, cl_strerror(scanret)); |
|
103 |
+ logg("%s: %s\n ERROR", fname, cl_strerror(scanret)); |
|
104 | 104 |
} |
105 | 105 |
} |
106 | 106 |
|
... | ... |
@@ -155,8 +155,8 @@ void clamscan(struct optstruct *opt) |
155 | 155 |
mprintf("Data scanned: %2.2lf MB\n", mb); |
156 | 156 |
logg("Data scanned: %2.2lf MB\n", mb); |
157 | 157 |
|
158 |
- mprintf("I/O buffer size: %d bytes\n", BUFFSIZE); |
|
159 |
- logg("I/O buffer size: %d bytes\n", BUFFSIZE); |
|
158 |
+ mprintf("I/O buffer size: %d bytes\n", SCANBUFF); |
|
159 |
+ logg("I/O buffer size: %d bytes\n", SCANBUFF); |
|
160 | 160 |
mprintf("Time: %d.%3.3d sec (%d m %d s)\n", ds, dms/1000, ds/60, ds%60); |
161 | 161 |
logg("Time: %d.%3.3d sec (%d m %d s)\n", ds, dms/1000, ds/60, ds%60); |
162 | 162 |
} |
... | ... |
@@ -7692,11 +7692,11 @@ LIBTOOL='$(SHELL) $(top_builddir)/libtool' |
7692 | 7692 |
|
7693 | 7693 |
|
7694 | 7694 |
cat >>confdefs.h <<\_ACEOF |
7695 |
-#define BUFFSIZE 131072 |
|
7695 |
+#define SCANBUFF 131072 |
|
7696 | 7696 |
_ACEOF |
7697 | 7697 |
|
7698 | 7698 |
cat >>confdefs.h <<\_ACEOF |
7699 |
-#define FBUFFSIZE 16384 |
|
7699 |
+#define FILEBUFF 8192 |
|
7700 | 7700 |
_ACEOF |
7701 | 7701 |
|
7702 | 7702 |
|
... | ... |
@@ -48,8 +48,8 @@ dnl AC_SUBST(LT_AGE) |
48 | 48 |
|
49 | 49 |
dnl BUFFSIZE must be at least 16 kb !!! |
50 | 50 |
|
51 |
-AC_DEFINE(BUFFSIZE, 131072) |
|
52 |
-AC_DEFINE(FBUFFSIZE, 16384) |
|
51 |
+AC_DEFINE(SCANBUFF, 131072) |
|
52 |
+AC_DEFINE(FILEBUFF, 8192) |
|
53 | 53 |
|
54 | 54 |
AC_HEADER_STDC |
55 | 55 |
AC_CHECK_HEADERS(stdint.h unistd.h sys/int_types.h dlfcn.h inttypes.h sys/inttypes.h memory.h ndir.h stdlib.h strings.h string.h sys/mman.h sys/param.h sys/stat.h sys/types.h malloc.h) |
... | ... |
@@ -316,7 +316,7 @@ int wwwconnect(const char *server, const char *proxy, char *ip) |
316 | 316 |
/* TODO: use a HEAD instruction to see if the file has been changed */ |
317 | 317 |
struct cl_cvd *remote_cvdhead(const char *file, int socketfd, const char *hostname, const char *proxy, const char *user) |
318 | 318 |
{ |
319 |
- char cmd[512], head[513], buffer[FBUFFSIZE], *ch, *tmp; |
|
319 |
+ char cmd[512], head[513], buffer[FILEBUFF], *ch, *tmp; |
|
320 | 320 |
int i, j, bread, cnt; |
321 | 321 |
char *remotename = NULL, *authorization = NULL; |
322 | 322 |
struct cl_cvd *cvd; |
... | ... |
@@ -359,7 +359,7 @@ struct cl_cvd *remote_cvdhead(const char *file, int socketfd, const char *hostna |
359 | 359 |
free(authorization); |
360 | 360 |
|
361 | 361 |
tmp = buffer; |
362 |
- cnt = FBUFFSIZE; |
|
362 |
+ cnt = FILEBUFF; |
|
363 | 363 |
while ((bread = recv(socketfd, tmp, cnt, 0)) > 0) { |
364 | 364 |
tmp+=bread; |
365 | 365 |
cnt-=bread; |
... | ... |
@@ -411,7 +411,7 @@ struct cl_cvd *remote_cvdhead(const char *file, int socketfd, const char *hostna |
411 | 411 |
int |
412 | 412 |
get_database(const char *dbfile, int socketfd, const char *file, const char *hostname, const char *proxy, const char *user) |
413 | 413 |
{ |
414 |
- char cmd[512], buffer[FBUFFSIZE]; |
|
414 |
+ char cmd[512], buffer[FILEBUFF]; |
|
415 | 415 |
char *ch; |
416 | 416 |
int bread, fd, i, rot = 0; |
417 | 417 |
char *remotename = NULL, *authorization = NULL; |
... | ... |
@@ -459,7 +459,7 @@ get_database(const char *dbfile, int socketfd, const char *file, const char *hos |
459 | 459 |
free(remotename); |
460 | 460 |
free(authorization); |
461 | 461 |
|
462 |
- if ((bread = recv(socketfd, buffer, FBUFFSIZE, 0)) == -1) { |
|
462 |
+ if ((bread = recv(socketfd, buffer, FILEBUFF, 0)) == -1) { |
|
463 | 463 |
mprintf("@Error while reading database from %s\n", hostname); |
464 | 464 |
return -1; |
465 | 465 |
} |
... | ... |
@@ -482,7 +482,7 @@ get_database(const char *dbfile, int socketfd, const char *file, const char *hos |
482 | 482 |
} |
483 | 483 |
|
484 | 484 |
write(fd, ch, bread - i); |
485 |
- while((bread = read(socketfd, buffer, FBUFFSIZE))) { |
|
485 |
+ while((bread = read(socketfd, buffer, FILEBUFF))) { |
|
486 | 486 |
write(fd, buffer, bread); |
487 | 487 |
mprintf("Downloading %s [%c]\r", dbfile, rotation[rot]); |
488 | 488 |
fflush(stdout); |
... | ... |
@@ -263,7 +263,7 @@ int cl_cvdverify(const char *file) |
263 | 263 |
|
264 | 264 |
int cli_cvdload(FILE *fd, struct cl_node **root, int *virnum) |
265 | 265 |
{ |
266 |
- char *dir, *tmp, buffer[BUFFSIZE]; |
|
266 |
+ char *dir, *tmp, *buffer; |
|
267 | 267 |
int bytes, ret; |
268 | 268 |
const char *tmpdir; |
269 | 269 |
FILE *tmpd; |
... | ... |
@@ -310,11 +310,17 @@ int cli_cvdload(FILE *fd, struct cl_node **root, int *virnum) |
310 | 310 |
cli_errmsg("Can't create temporary file %s\n", tmp); |
311 | 311 |
free(dir); |
312 | 312 |
free(tmp); |
313 |
- return -1; |
|
313 |
+ return CL_ETMPFILE; |
|
314 | 314 |
} |
315 |
- while((bytes = fread(buffer, 1, BUFFSIZE, fd)) > 0) |
|
315 |
+ |
|
316 |
+ if(!(buffer = (char *) cli_malloc(FILEBUFF))) |
|
317 |
+ return CL_EMEM; |
|
318 |
+ |
|
319 |
+ while((bytes = fread(buffer, 1, FILEBUFF, fd)) > 0) |
|
316 | 320 |
fwrite(buffer, 1, bytes, tmpd); |
317 | 321 |
|
322 |
+ free(buffer); |
|
323 |
+ |
|
318 | 324 |
fflush(tmpd); |
319 | 325 |
fseek(tmpd, 0L, SEEK_SET); |
320 | 326 |
|
... | ... |
@@ -79,7 +79,7 @@ int cli_parse_add(struct cl_node *root, const char *virname, const char *hexstr, |
79 | 79 |
int cl_loaddb(const char *filename, struct cl_node **root, int *virnum) |
80 | 80 |
{ |
81 | 81 |
FILE *fd; |
82 |
- char buffer[BUFFSIZE], *pt, *start, *pt2; |
|
82 |
+ char *buffer, *pt, *start, *pt2; |
|
83 | 83 |
int line = 0, ret, parts, i, sigid = 0; |
84 | 84 |
|
85 | 85 |
|
... | ... |
@@ -90,6 +90,9 @@ int cl_loaddb(const char *filename, struct cl_node **root, int *virnum) |
90 | 90 |
|
91 | 91 |
cli_dbgmsg("Loading %s\n", filename); |
92 | 92 |
|
93 |
+ if(!(buffer = (char *) cli_malloc(FILEBUFF))) |
|
94 |
+ return CL_EMEM; |
|
95 |
+ |
|
93 | 96 |
/* check for CVD file */ |
94 | 97 |
fgets(buffer, 12, fd); |
95 | 98 |
rewind(fd); |
... | ... |
@@ -98,10 +101,11 @@ int cl_loaddb(const char *filename, struct cl_node **root, int *virnum) |
98 | 98 |
cli_dbgmsg("%s: CVD file detected\n", filename); |
99 | 99 |
ret = cli_cvdload(fd, root, virnum); |
100 | 100 |
fclose(fd); |
101 |
+ free(buffer); |
|
101 | 102 |
return ret; |
102 | 103 |
} |
103 | 104 |
|
104 |
- while(fgets(buffer, BUFFSIZE, fd)) { |
|
105 |
+ while(fgets(buffer, FILEBUFF, fd)) { |
|
105 | 106 |
|
106 | 107 |
/* for forward compatibility */ |
107 | 108 |
if(strchr(buffer, '{') || strchr(buffer, '}')) { |
... | ... |
@@ -115,6 +119,7 @@ int cl_loaddb(const char *filename, struct cl_node **root, int *virnum) |
115 | 115 |
pt = strchr(buffer, '='); |
116 | 116 |
if(!pt) { |
117 | 117 |
cli_errmsg("readdb(): Malformed pattern line %d (file %s).\n", line, filename); |
118 |
+ free(buffer); |
|
118 | 119 |
return CL_EMALFDB; |
119 | 120 |
} |
120 | 121 |
|
... | ... |
@@ -126,8 +131,10 @@ int cl_loaddb(const char *filename, struct cl_node **root, int *virnum) |
126 | 126 |
if(!*root) { |
127 | 127 |
cli_dbgmsg("Initializing trie.\n"); |
128 | 128 |
*root = (struct cl_node *) cli_calloc(1, sizeof(struct cl_node)); |
129 |
- if(!*root) |
|
129 |
+ if(!*root) { |
|
130 |
+ free(buffer); |
|
130 | 131 |
return CL_EMEM; |
132 |
+ } |
|
131 | 133 |
(*root)->maxpatlen = 0; |
132 | 134 |
} |
133 | 135 |
|
... | ... |
@@ -146,6 +153,7 @@ int cl_loaddb(const char *filename, struct cl_node **root, int *virnum) |
146 | 146 |
if((ret = cli_parse_add(*root, start, pt2, sigid, parts, i))) { |
147 | 147 |
cli_dbgmsg("parse_add() return code: %d\n", ret); |
148 | 148 |
cli_errmsg("readdb(): Malformed pattern line %d (file %s).\n", line, filename); |
149 |
+ free(buffer); |
|
149 | 150 |
return ret; |
150 | 151 |
} |
151 | 152 |
//cli_dbgmsg("Added part %d of partial signature (id %d)\n", i, sigid); |
... | ... |
@@ -156,11 +164,13 @@ int cl_loaddb(const char *filename, struct cl_node **root, int *virnum) |
156 | 156 |
if((ret = cli_parse_add(*root, start, pt, 0, 0, 0))) { |
157 | 157 |
cli_dbgmsg("parse_add() return code: %d\n", ret); |
158 | 158 |
cli_errmsg("readdb(): Malformed pattern line %d (file %s).\n", line, filename); |
159 |
+ free(buffer); |
|
159 | 160 |
return ret; |
160 | 161 |
} |
161 | 162 |
} |
162 | 163 |
} |
163 | 164 |
|
165 |
+ free(buffer); |
|
164 | 166 |
fclose(fd); |
165 | 167 |
if(virnum != NULL) |
166 | 168 |
*virnum += line; |
... | ... |
@@ -72,33 +72,33 @@ cl_node *root) |
72 | 72 |
|
73 | 73 |
|
74 | 74 |
/* prepare the buffer */ |
75 |
- buffsize = root->maxpatlen + BUFFSIZE; |
|
75 |
+ buffsize = root->maxpatlen + SCANBUFF; |
|
76 | 76 |
if(!(buffer = (char *) cli_calloc(buffsize, sizeof(char)))) |
77 | 77 |
return CL_EMEM; |
78 | 78 |
|
79 | 79 |
buff = buffer; |
80 | 80 |
buff += root->maxpatlen; /* pointer to read data block */ |
81 |
- endbl = buff + BUFFSIZE - root->maxpatlen; /* pointer to the last block |
|
81 |
+ endbl = buff + SCANBUFF - root->maxpatlen; /* pointer to the last block |
|
82 | 82 |
* length of root->maxpatlen |
83 | 83 |
*/ |
84 | 84 |
|
85 | 85 |
pt= buff; |
86 |
- length = BUFFSIZE; |
|
86 |
+ length = SCANBUFF; |
|
87 | 87 |
|
88 |
- while((bytes = read(desc, buff, BUFFSIZE)) > 0) { |
|
88 |
+ while((bytes = read(desc, buff, SCANBUFF)) > 0) { |
|
89 | 89 |
|
90 | 90 |
if(scanned != NULL) |
91 | 91 |
*scanned += bytes / CL_COUNT_PRECISION; |
92 | 92 |
|
93 |
- if(bytes < BUFFSIZE) |
|
94 |
- length -= BUFFSIZE - bytes; |
|
93 |
+ if(bytes < SCANBUFF) |
|
94 |
+ length -= SCANBUFF - bytes; |
|
95 | 95 |
|
96 | 96 |
if(cl_scanbuff(pt, length, virname, root) == CL_VIRUS) { |
97 | 97 |
free(buffer); |
98 | 98 |
return CL_VIRUS; |
99 | 99 |
} |
100 | 100 |
|
101 |
- if(bytes == BUFFSIZE) |
|
101 |
+ if(bytes == SCANBUFF) |
|
102 | 102 |
memmove(buffer, endbl, root->maxpatlen); |
103 | 103 |
|
104 | 104 |
pt = buffer; |
... | ... |
@@ -241,7 +241,7 @@ int cli_scanzip(int desc, char **virname, long int *scanned, const struct cl_nod |
241 | 241 |
ZZIP_DIRENT zdirent; |
242 | 242 |
ZZIP_FILE *zfp; |
243 | 243 |
FILE *tmp; |
244 |
- char buff[BUFFSIZE]; |
|
244 |
+ char *buff; |
|
245 | 245 |
int fd, bytes, files = 0, ret = CL_CLEAN, err; |
246 | 246 |
|
247 | 247 |
|
... | ... |
@@ -297,17 +297,22 @@ int cli_scanzip(int desc, char **virname, long int *scanned, const struct cl_nod |
297 | 297 |
continue; |
298 | 298 |
} |
299 | 299 |
|
300 |
- while((bytes = zzip_file_read(zfp, buff, BUFFSIZE)) > 0) { |
|
300 |
+ if(!(buff = (char *) cli_malloc(FILEBUFF))) |
|
301 |
+ return CL_EMEM; |
|
302 |
+ |
|
303 |
+ while((bytes = zzip_file_read(zfp, buff, FILEBUFF)) > 0) { |
|
301 | 304 |
if(fwrite(buff, bytes, 1, tmp)*bytes != bytes) { |
302 | 305 |
cli_dbgmsg("Zip -> Can't fwrite() file: %s\n", strerror(errno)); |
303 | 306 |
zzip_file_close(zfp); |
304 | 307 |
zzip_dir_close(zdir); |
305 | 308 |
files++; |
306 | 309 |
fclose(tmp); |
310 |
+ free(buff); |
|
307 | 311 |
return CL_EZIP; |
308 | 312 |
} |
309 | 313 |
} |
310 | 314 |
|
315 |
+ free(buff); |
|
311 | 316 |
zzip_file_close(zfp); |
312 | 317 |
|
313 | 318 |
if(fflush(tmp) != 0) { |
... | ... |
@@ -358,7 +363,7 @@ int cli_scangzip(int desc, char **virname, long int *scanned, const struct cl_no |
358 | 358 |
{ |
359 | 359 |
int fd, bytes, ret = CL_CLEAN; |
360 | 360 |
long int size = 0; |
361 |
- char buff[BUFFSIZE]; |
|
361 |
+ char *buff; |
|
362 | 362 |
FILE *tmp; |
363 | 363 |
gzFile gd; |
364 | 364 |
|
... | ... |
@@ -375,11 +380,14 @@ int cli_scangzip(int desc, char **virname, long int *scanned, const struct cl_no |
375 | 375 |
} |
376 | 376 |
fd = fileno(tmp); |
377 | 377 |
|
378 |
- while((bytes = gzread(gd, buff, BUFFSIZE)) > 0) { |
|
378 |
+ if(!(buff = (char *) cli_malloc(FILEBUFF))) |
|
379 |
+ return CL_EMEM; |
|
380 |
+ |
|
381 |
+ while((bytes = gzread(gd, buff, SCANBUFF)) > 0) { |
|
379 | 382 |
size += bytes; |
380 | 383 |
|
381 | 384 |
if(limits) |
382 |
- if(limits->maxfilesize && (size + BUFFSIZE > limits->maxfilesize)) { |
|
385 |
+ if(limits->maxfilesize && (size + SCANBUFF > limits->maxfilesize)) { |
|
383 | 386 |
cli_dbgmsg("Gzip->desc(%d): Size exceeded (stopped at %d, max: %d)\n", desc, size, limits->maxfilesize); |
384 | 387 |
ret = CL_EMAXSIZE; |
385 | 388 |
break; |
... | ... |
@@ -389,10 +397,12 @@ int cli_scangzip(int desc, char **virname, long int *scanned, const struct cl_no |
389 | 389 |
cli_dbgmsg("Gzip -> Can't write() file.\n"); |
390 | 390 |
fclose(tmp); |
391 | 391 |
gzclose(gd); |
392 |
+ free(buff); |
|
392 | 393 |
return CL_EGZIP; |
393 | 394 |
} |
394 | 395 |
} |
395 | 396 |
|
397 |
+ free(buff); |
|
396 | 398 |
gzclose(gd); |
397 | 399 |
if(fsync(fd) == -1) { |
398 | 400 |
cli_dbgmsg("fsync() failed for descriptor %d\n", fd); |
... | ... |
@@ -425,7 +435,7 @@ int cli_scanbzip(int desc, char **virname, long int *scanned, const struct cl_no |
425 | 425 |
int fd, bytes, ret = CL_CLEAN, bzerror = 0; |
426 | 426 |
short memlim = 0; |
427 | 427 |
long int size = 0; |
428 |
- char buff[BUFFSIZE]; |
|
428 |
+ char *buff; |
|
429 | 429 |
FILE *fs, *tmp; |
430 | 430 |
BZFILE *bfd; |
431 | 431 |
|
... | ... |
@@ -451,11 +461,14 @@ int cli_scanbzip(int desc, char **virname, long int *scanned, const struct cl_no |
451 | 451 |
} |
452 | 452 |
fd = fileno(tmp); |
453 | 453 |
|
454 |
- while((bytes = BZ2_bzRead(&bzerror, bfd, buff, BUFFSIZE)) > 0) { |
|
454 |
+ if(!(buff = (char *) cli_malloc(FILEBUFF))) |
|
455 |
+ return CL_EMEM; |
|
456 |
+ |
|
457 |
+ while((bytes = BZ2_bzRead(&bzerror, bfd, buff, SCANBUFF)) > 0) { |
|
455 | 458 |
size += bytes; |
456 | 459 |
|
457 | 460 |
if(limits) |
458 |
- if(limits->maxfilesize && (size + BUFFSIZE > limits->maxfilesize)) { |
|
461 |
+ if(limits->maxfilesize && (size + SCANBUFF > limits->maxfilesize)) { |
|
459 | 462 |
cli_dbgmsg("Bzip2->desc(%d): Size exceeded (stopped at %d, max: %d)\n", desc, size, limits->maxfilesize); |
460 | 463 |
ret = CL_EMAXSIZE; |
461 | 464 |
break; |
... | ... |
@@ -465,10 +478,12 @@ int cli_scanbzip(int desc, char **virname, long int *scanned, const struct cl_no |
465 | 465 |
cli_dbgmsg("Bzip2 -> Can't write() file.\n"); |
466 | 466 |
BZ2_bzReadClose(&bzerror, bfd); |
467 | 467 |
fclose(tmp); |
468 |
+ free(buff); |
|
468 | 469 |
return CL_EGZIP; |
469 | 470 |
} |
470 | 471 |
} |
471 | 472 |
|
473 |
+ free(buff); |
|
472 | 474 |
BZ2_bzReadClose(&bzerror, bfd); |
473 | 475 |
if(fsync(fd) == -1) { |
474 | 476 |
cli_dbgmsg("fsync() failed for descriptor %d\n", fd); |
... | ... |
@@ -75,7 +75,7 @@ int scanfile(const char *cmd, const char *str, const char *file) |
75 | 75 |
|
76 | 76 |
char *cut(const char *file, long int start, long int end) |
77 | 77 |
{ |
78 |
- char *fname = NULL, buffer[FBUFFSIZE]; |
|
78 |
+ char *fname = NULL, buffer[FILEBUFF]; |
|
79 | 79 |
int bytes, size, sum; |
80 | 80 |
FILE *rd, *wd; |
81 | 81 |
|
... | ... |
@@ -100,7 +100,7 @@ char *cut(const char *file, long int start, long int end) |
100 | 100 |
size = end - start; |
101 | 101 |
sum = 0; |
102 | 102 |
|
103 |
- while((bytes = fread(buffer, 1, FBUFFSIZE, rd)) > 0) { |
|
103 |
+ while((bytes = fread(buffer, 1, FILEBUFF, rd)) > 0) { |
|
104 | 104 |
if(sum + bytes >= size) { |
105 | 105 |
fwrite(buffer, 1, size - sum, wd); |
106 | 106 |
break; |
... | ... |
@@ -118,7 +118,7 @@ char *cut(const char *file, long int start, long int end) |
118 | 118 |
|
119 | 119 |
char *change(const char *file, long int x) |
120 | 120 |
{ |
121 |
- char *fname = NULL, buffer[FBUFFSIZE]; |
|
121 |
+ char *fname = NULL, buffer[FILEBUFF]; |
|
122 | 122 |
int bytes, size, sum, ch; |
123 | 123 |
FILE *rd, *wd; |
124 | 124 |
|
... | ... |
@@ -138,7 +138,7 @@ char *change(const char *file, long int x) |
138 | 138 |
exit(14); |
139 | 139 |
} |
140 | 140 |
|
141 |
- while((bytes = fread(buffer, 1, FBUFFSIZE, rd)) > 0) |
|
141 |
+ while((bytes = fread(buffer, 1, FILEBUFF, rd)) > 0) |
|
142 | 142 |
fwrite(buffer, 1, bytes, wd); |
143 | 143 |
|
144 | 144 |
fclose(rd); |
... | ... |
@@ -157,7 +157,7 @@ char *change(const char *file, long int x) |
157 | 157 |
|
158 | 158 |
void sigtool(struct optstruct *opt) |
159 | 159 |
{ |
160 |
- char buffer[FBUFFSIZE]; |
|
160 |
+ char buffer[FILEBUFF]; |
|
161 | 161 |
int bytes; |
162 | 162 |
char *pt; |
163 | 163 |
|
... | ... |
@@ -183,7 +183,7 @@ void sigtool(struct optstruct *opt) |
183 | 183 |
|
184 | 184 |
if(optl(opt, "hex-dump")) { |
185 | 185 |
|
186 |
- while((bytes = read(0, buffer, FBUFFSIZE)) > 0) { |
|
186 |
+ while((bytes = read(0, buffer, FILEBUFF)) > 0) { |
|
187 | 187 |
pt = cl_str2hex(buffer, bytes); |
188 | 188 |
write(1, pt, 2 * bytes); |
189 | 189 |
free(pt); |
... | ... |
@@ -420,7 +420,7 @@ void sigtool(struct optstruct *opt) |
420 | 420 |
|
421 | 421 |
mprintf("Saving signature in %s file.\n", signame); |
422 | 422 |
|
423 |
- while((bytes = fread(buffer, 1, FBUFFSIZE, fd)) > 0) { |
|
423 |
+ while((bytes = fread(buffer, 1, FILEBUFF, fd)) > 0) { |
|
424 | 424 |
pt = cl_str2hex(buffer, bytes); |
425 | 425 |
fwrite(pt, 1, 2 * bytes, wd); |
426 | 426 |
free(pt); |
... | ... |
@@ -459,7 +459,7 @@ int build(struct optstruct *opt) |
459 | 459 |
{ |
460 | 460 |
int ret, no = 0, realno = 0, bytes, itmp; |
461 | 461 |
struct stat foo; |
462 |
- char buffer[BUFFSIZE], *tarfile = NULL, *gzfile = NULL, header[257], |
|
462 |
+ char buffer[FILEBUFF], *tarfile = NULL, *gzfile = NULL, header[257], |
|
463 | 463 |
smbuff[25], *pt; |
464 | 464 |
struct cl_node *root = NULL; |
465 | 465 |
FILE *tar, *cvd, *fd; |
... | ... |
@@ -542,7 +542,7 @@ int build(struct optstruct *opt) |
542 | 542 |
exit(1); |
543 | 543 |
} |
544 | 544 |
|
545 |
- while((bytes = fread(buffer, 1, BUFFSIZE, tar)) > 0) |
|
545 |
+ while((bytes = fread(buffer, 1, FILEBUFF, tar)) > 0) |
|
546 | 546 |
gzwrite(gz, buffer, bytes); |
547 | 547 |
|
548 | 548 |
fclose(tar); |
... | ... |
@@ -647,7 +647,7 @@ int build(struct optstruct *opt) |
647 | 647 |
exit(1); |
648 | 648 |
} |
649 | 649 |
|
650 |
- while((bytes = fread(buffer, 1, BUFFSIZE, tar)) > 0) |
|
650 |
+ while((bytes = fread(buffer, 1, FILEBUFF, tar)) > 0) |
|
651 | 651 |
fwrite(buffer, 1, bytes, cvd); |
652 | 652 |
|
653 | 653 |
fclose(tar); |