git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@84 77e5149b-7576-45b1-b177-96237e5ba77b
Tomasz Kojm authored on 2003/10/17 12:16:14... | ... |
@@ -1,3 +1,16 @@ |
1 |
+Fri Oct 17 05:08:22 CEST 2003 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * new Spanish documentation on ClamAV + Sendmail integration by |
|
4 |
+ Erick Ivaan Lopez Carreon |
|
5 |
+ * freshclam: share cfgfile.o with clamd. Makefile conditions allow building |
|
6 |
+ without clamd (if pthread library is not available). The problem |
|
7 |
+ with outdated cfgfile.c in freshclam was reported by Jim C. |
|
8 |
+ * clamd: fixed a segmentation fault with TCPAddr. Problem reported by |
|
9 |
+ Stefan Kaltenbrunner and fixed by Damien Curtain. |
|
10 |
+ * libclamav: zziplib downgroaded to 0.10.81 with Martin Schitter's hardening |
|
11 |
+ patches |
|
12 |
+ * sigtool: major stability fixes |
|
13 |
+ |
|
1 | 14 |
Sun Oct 12 21:14:21 BST 2003 (njh) |
2 | 15 |
--------------------------------- |
3 | 16 |
* libclamav: mbox.c now uses NO_STRTOK_R consistently with message.c |
... | ... |
@@ -15,5 +15,5 @@ |
15 | 15 |
# along with this program; if not, write to the Free Software |
16 | 16 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
17 | 17 |
|
18 |
-SUBDIRS = libclamav clamscan freshclam database docs sigtool clamd clamdscan clamav-milter etc |
|
18 |
+SUBDIRS = libclamav clamscan clamd clamdscan freshclam sigtool database docs etc clamav-milter |
|
19 | 19 |
EXTRA_DIST = FAQ contrib test examples BUGS |
... | ... |
@@ -114,7 +114,7 @@ am__include = @am__include@ |
114 | 114 |
am__quote = @am__quote@ |
115 | 115 |
install_sh = @install_sh@ |
116 | 116 |
|
117 |
-SUBDIRS = libclamav clamscan freshclam database docs sigtool clamd clamdscan clamav-milter etc |
|
117 |
+SUBDIRS = libclamav clamscan clamd clamdscan freshclam sigtool database docs etc clamav-milter |
|
118 | 118 |
EXTRA_DIST = FAQ contrib test examples BUGS |
119 | 119 |
subdir = . |
120 | 120 |
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
... | ... |
@@ -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.6 2003/10/12 17:51:08 kojm Exp $ |
|
84 |
+dnl @version: $Id: aclocal.m4,v 1.7 2003/10/17 03:16:14 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.6 2003/10/12 17:51:08 kojm Exp $ |
|
4044 |
+dnl @version $Id: aclocal.m4,v 1.7 2003/10/17 03:16:14 kojm Exp $ |
|
4045 | 4045 |
dnl |
4046 | 4046 |
AC_DEFUN([AC_COMPILE_CHECK_SIZEOF], |
4047 | 4047 |
[changequote(<<, >>)dnl |
... | ... |
@@ -116,13 +116,13 @@ install_sh = @install_sh@ |
116 | 116 |
|
117 | 117 |
|
118 | 118 |
# FIXME: check automake for 'and' (&&) |
119 |
-@HAVE_MILTER_TRUE@@USE_PTHREAD_TRUE@sbin_PROGRAMS = clamav-milter |
|
119 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@sbin_PROGRAMS = clamav-milter |
|
120 | 120 |
|
121 |
-@HAVE_MILTER_TRUE@@USE_PTHREAD_TRUE@clamav_milter_SOURCES = clamav-milter.c |
|
121 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@clamav_milter_SOURCES = clamav-milter.c |
|
122 | 122 |
|
123 |
-@HAVE_MILTER_TRUE@@USE_PTHREAD_TRUE@clamav_milter_LDADD = ../clamd/cfgfile.o ../clamd/others.o ../clamscan/getopt.o |
|
123 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@clamav_milter_LDADD = ../clamd/cfgfile.o ../clamd/others.o ../clamscan/getopt.o |
|
124 | 124 |
|
125 |
-@HAVE_MILTER_TRUE@@USE_PTHREAD_TRUE@man_MANS = ../docs/clamav-milter.1 |
|
125 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@man_MANS = ../docs/clamav-milter.1 |
|
126 | 126 |
|
127 | 127 |
DEFS = @DEFS@ |
128 | 128 |
# CLAMD_LIBS is used, because clamav-milter requires the same libraries as clamd |
... | ... |
@@ -132,23 +132,23 @@ EXTRA_DIST = clamav-milter.c clamd.sh clamav-milter.sh INSTALL |
132 | 132 |
subdir = clamav-milter |
133 | 133 |
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs |
134 | 134 |
CONFIG_CLEAN_FILES = |
135 |
-@HAVE_MILTER_FALSE@@USE_PTHREAD_TRUE@sbin_PROGRAMS = |
|
136 |
-@HAVE_MILTER_FALSE@@USE_PTHREAD_FALSE@sbin_PROGRAMS = |
|
137 |
-@HAVE_MILTER_TRUE@@USE_PTHREAD_TRUE@sbin_PROGRAMS = \ |
|
138 |
-@HAVE_MILTER_TRUE@@USE_PTHREAD_TRUE@ clamav-milter$(EXEEXT) |
|
139 |
-@HAVE_MILTER_TRUE@@USE_PTHREAD_FALSE@sbin_PROGRAMS = |
|
135 |
+@BUILD_CLAMD_FALSE@@HAVE_MILTER_TRUE@sbin_PROGRAMS = |
|
136 |
+@BUILD_CLAMD_FALSE@@HAVE_MILTER_FALSE@sbin_PROGRAMS = |
|
137 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@sbin_PROGRAMS = \ |
|
138 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ clamav-milter$(EXEEXT) |
|
139 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_FALSE@sbin_PROGRAMS = |
|
140 | 140 |
PROGRAMS = $(sbin_PROGRAMS) |
141 | 141 |
|
142 |
-@HAVE_MILTER_TRUE@@USE_PTHREAD_TRUE@am_clamav_milter_OBJECTS = \ |
|
143 |
-@HAVE_MILTER_TRUE@@USE_PTHREAD_TRUE@ clamav-milter.$(OBJEXT) |
|
142 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@am_clamav_milter_OBJECTS = \ |
|
143 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ clamav-milter.$(OBJEXT) |
|
144 | 144 |
clamav_milter_OBJECTS = $(am_clamav_milter_OBJECTS) |
145 |
-@HAVE_MILTER_FALSE@@USE_PTHREAD_TRUE@clamav_milter_DEPENDENCIES = |
|
146 |
-@HAVE_MILTER_FALSE@@USE_PTHREAD_FALSE@clamav_milter_DEPENDENCIES = |
|
147 |
-@HAVE_MILTER_TRUE@@USE_PTHREAD_TRUE@clamav_milter_DEPENDENCIES = \ |
|
148 |
-@HAVE_MILTER_TRUE@@USE_PTHREAD_TRUE@ ../clamd/cfgfile.o \ |
|
149 |
-@HAVE_MILTER_TRUE@@USE_PTHREAD_TRUE@ ../clamd/others.o \ |
|
150 |
-@HAVE_MILTER_TRUE@@USE_PTHREAD_TRUE@ ../clamscan/getopt.o |
|
151 |
-@HAVE_MILTER_TRUE@@USE_PTHREAD_FALSE@clamav_milter_DEPENDENCIES = |
|
145 |
+@BUILD_CLAMD_FALSE@@HAVE_MILTER_TRUE@clamav_milter_DEPENDENCIES = |
|
146 |
+@BUILD_CLAMD_FALSE@@HAVE_MILTER_FALSE@clamav_milter_DEPENDENCIES = |
|
147 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@clamav_milter_DEPENDENCIES = \ |
|
148 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ ../clamd/cfgfile.o \ |
|
149 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ ../clamd/others.o \ |
|
150 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ ../clamscan/getopt.o |
|
151 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_FALSE@clamav_milter_DEPENDENCIES = |
|
152 | 152 |
clamav_milter_LDFLAGS = |
153 | 153 |
DEFAULT_INCLUDES = -I. -I$(srcdir) |
154 | 154 |
CPPFLAGS = @CPPFLAGS@ |
... | ... |
@@ -114,35 +114,35 @@ am__include = @am__include@ |
114 | 114 |
am__quote = @am__quote@ |
115 | 115 |
install_sh = @install_sh@ |
116 | 116 |
|
117 |
-@USE_PTHREAD_TRUE@sbin_PROGRAMS = clamd |
|
118 |
- |
|
119 |
-@USE_PTHREAD_TRUE@clamd_SOURCES = \ |
|
120 |
-@USE_PTHREAD_TRUE@ options.c \ |
|
121 |
-@USE_PTHREAD_TRUE@ options.h \ |
|
122 |
-@USE_PTHREAD_TRUE@ cfgfile.c \ |
|
123 |
-@USE_PTHREAD_TRUE@ cfgfile.h \ |
|
124 |
-@USE_PTHREAD_TRUE@ clamd.c \ |
|
125 |
-@USE_PTHREAD_TRUE@ defaults.h \ |
|
126 |
-@USE_PTHREAD_TRUE@ tcpserver.c \ |
|
127 |
-@USE_PTHREAD_TRUE@ tcpserver.h \ |
|
128 |
-@USE_PTHREAD_TRUE@ localserver.c \ |
|
129 |
-@USE_PTHREAD_TRUE@ localserver.h \ |
|
130 |
-@USE_PTHREAD_TRUE@ server.c \ |
|
131 |
-@USE_PTHREAD_TRUE@ server.h \ |
|
132 |
-@USE_PTHREAD_TRUE@ scanner.c \ |
|
133 |
-@USE_PTHREAD_TRUE@ scanner.h \ |
|
134 |
-@USE_PTHREAD_TRUE@ others.c \ |
|
135 |
-@USE_PTHREAD_TRUE@ others.h \ |
|
136 |
-@USE_PTHREAD_TRUE@ clamuko.c \ |
|
137 |
-@USE_PTHREAD_TRUE@ clamuko.h \ |
|
138 |
-@USE_PTHREAD_TRUE@ dazuko.h \ |
|
139 |
-@USE_PTHREAD_TRUE@ dazukoio.c \ |
|
140 |
-@USE_PTHREAD_TRUE@ dazukoio.h \ |
|
141 |
-@USE_PTHREAD_TRUE@ tests.c \ |
|
142 |
-@USE_PTHREAD_TRUE@ tests.h |
|
143 |
- |
|
144 |
- |
|
145 |
-@USE_PTHREAD_TRUE@clamd_LDADD = ../clamscan/getopt.o |
|
117 |
+@BUILD_CLAMD_TRUE@sbin_PROGRAMS = clamd |
|
118 |
+ |
|
119 |
+@BUILD_CLAMD_TRUE@clamd_SOURCES = \ |
|
120 |
+@BUILD_CLAMD_TRUE@ options.c \ |
|
121 |
+@BUILD_CLAMD_TRUE@ options.h \ |
|
122 |
+@BUILD_CLAMD_TRUE@ cfgfile.c \ |
|
123 |
+@BUILD_CLAMD_TRUE@ cfgfile.h \ |
|
124 |
+@BUILD_CLAMD_TRUE@ clamd.c \ |
|
125 |
+@BUILD_CLAMD_TRUE@ defaults.h \ |
|
126 |
+@BUILD_CLAMD_TRUE@ tcpserver.c \ |
|
127 |
+@BUILD_CLAMD_TRUE@ tcpserver.h \ |
|
128 |
+@BUILD_CLAMD_TRUE@ localserver.c \ |
|
129 |
+@BUILD_CLAMD_TRUE@ localserver.h \ |
|
130 |
+@BUILD_CLAMD_TRUE@ server.c \ |
|
131 |
+@BUILD_CLAMD_TRUE@ server.h \ |
|
132 |
+@BUILD_CLAMD_TRUE@ scanner.c \ |
|
133 |
+@BUILD_CLAMD_TRUE@ scanner.h \ |
|
134 |
+@BUILD_CLAMD_TRUE@ others.c \ |
|
135 |
+@BUILD_CLAMD_TRUE@ others.h \ |
|
136 |
+@BUILD_CLAMD_TRUE@ clamuko.c \ |
|
137 |
+@BUILD_CLAMD_TRUE@ clamuko.h \ |
|
138 |
+@BUILD_CLAMD_TRUE@ dazuko.h \ |
|
139 |
+@BUILD_CLAMD_TRUE@ dazukoio.c \ |
|
140 |
+@BUILD_CLAMD_TRUE@ dazukoio.h \ |
|
141 |
+@BUILD_CLAMD_TRUE@ tests.c \ |
|
142 |
+@BUILD_CLAMD_TRUE@ tests.h |
|
143 |
+ |
|
144 |
+ |
|
145 |
+@BUILD_CLAMD_TRUE@clamd_LDADD = ../clamscan/getopt.o |
|
146 | 146 |
|
147 | 147 |
DEFS = @DEFS@ |
148 | 148 |
LIBS = -L../libclamav -lclamav @CLAMD_LIBS@ |
... | ... |
@@ -150,19 +150,19 @@ INCLUDES = -I../clamscan -I../libclamav |
150 | 150 |
subdir = clamd |
151 | 151 |
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs |
152 | 152 |
CONFIG_CLEAN_FILES = |
153 |
-@USE_PTHREAD_TRUE@sbin_PROGRAMS = clamd$(EXEEXT) |
|
154 |
-@USE_PTHREAD_FALSE@sbin_PROGRAMS = |
|
153 |
+@BUILD_CLAMD_TRUE@sbin_PROGRAMS = clamd$(EXEEXT) |
|
154 |
+@BUILD_CLAMD_FALSE@sbin_PROGRAMS = |
|
155 | 155 |
PROGRAMS = $(sbin_PROGRAMS) |
156 | 156 |
|
157 |
-@USE_PTHREAD_TRUE@am_clamd_OBJECTS = options.$(OBJEXT) cfgfile.$(OBJEXT) \ |
|
158 |
-@USE_PTHREAD_TRUE@ clamd.$(OBJEXT) tcpserver.$(OBJEXT) \ |
|
159 |
-@USE_PTHREAD_TRUE@ localserver.$(OBJEXT) server.$(OBJEXT) \ |
|
160 |
-@USE_PTHREAD_TRUE@ scanner.$(OBJEXT) others.$(OBJEXT) \ |
|
161 |
-@USE_PTHREAD_TRUE@ clamuko.$(OBJEXT) dazukoio.$(OBJEXT) \ |
|
162 |
-@USE_PTHREAD_TRUE@ tests.$(OBJEXT) |
|
157 |
+@BUILD_CLAMD_TRUE@am_clamd_OBJECTS = options.$(OBJEXT) cfgfile.$(OBJEXT) \ |
|
158 |
+@BUILD_CLAMD_TRUE@ clamd.$(OBJEXT) tcpserver.$(OBJEXT) \ |
|
159 |
+@BUILD_CLAMD_TRUE@ localserver.$(OBJEXT) server.$(OBJEXT) \ |
|
160 |
+@BUILD_CLAMD_TRUE@ scanner.$(OBJEXT) others.$(OBJEXT) \ |
|
161 |
+@BUILD_CLAMD_TRUE@ clamuko.$(OBJEXT) dazukoio.$(OBJEXT) \ |
|
162 |
+@BUILD_CLAMD_TRUE@ tests.$(OBJEXT) |
|
163 | 163 |
clamd_OBJECTS = $(am_clamd_OBJECTS) |
164 |
-@USE_PTHREAD_TRUE@clamd_DEPENDENCIES = ../clamscan/getopt.o |
|
165 |
-@USE_PTHREAD_FALSE@clamd_DEPENDENCIES = |
|
164 |
+@BUILD_CLAMD_TRUE@clamd_DEPENDENCIES = ../clamscan/getopt.o |
|
165 |
+@BUILD_CLAMD_FALSE@clamd_DEPENDENCIES = |
|
166 | 166 |
clamd_LDFLAGS = |
167 | 167 |
DEFAULT_INCLUDES = -I. -I$(srcdir) |
168 | 168 |
CPPFLAGS = @CPPFLAGS@ |
... | ... |
@@ -35,16 +35,16 @@ int tcpserver(const struct optstruct *opt, const struct cfgstruct *copt, struct |
35 | 35 |
struct sockaddr_in server; |
36 | 36 |
int sockfd, backlog; |
37 | 37 |
struct cfgstruct *cpt; |
38 |
+ struct cfgstruct *taddr; |
|
38 | 39 |
char *estr; |
39 |
- const char *taddr; |
|
40 | 40 |
|
41 | 41 |
memset((char *) &server, 0, sizeof(server)); |
42 | 42 |
server.sin_family = AF_INET; |
43 | 43 |
server.sin_port = htons(cfgopt(copt, "TCPSocket")->numarg); |
44 |
- taddr = cfgopt(copt, "TCPAddr")->strarg; |
|
45 |
- if ( taddr != NULL && *taddr ) |
|
44 |
+ |
|
45 |
+ if (taddr = cfgopt(copt, "TCPAddr")) |
|
46 | 46 |
{ |
47 |
- server.sin_addr.s_addr = inet_addr( taddr ); |
|
47 |
+ server.sin_addr.s_addr = inet_addr( taddr->strarg ); |
|
48 | 48 |
}else |
49 | 49 |
{ |
50 | 50 |
server.sin_addr.s_addr = INADDR_ANY; |
... | ... |
@@ -64,8 +64,8 @@ int tcpserver(const struct optstruct *opt, const struct cfgstruct *copt, struct |
64 | 64 |
logg("!bind() error: %s\n", estr); |
65 | 65 |
exit(1); |
66 | 66 |
} else { |
67 |
- if ( taddr != NULL && *taddr ) |
|
68 |
- logg("Bound to address %s on port %d\n", taddr, cfgopt(copt, "TCPSocket")->numarg); |
|
67 |
+ if ( taddr != NULL && *taddr->strarg ) |
|
68 |
+ logg("Bound to address %s on port %d\n", taddr->strarg, cfgopt(copt, "TCPSocket")->numarg); |
|
69 | 69 |
else |
70 | 70 |
logg("Bound to port %d\n", cfgopt(copt, "TCPSocket")->numarg); |
71 | 71 |
} |
... | ... |
@@ -114,34 +114,34 @@ am__include = @am__include@ |
114 | 114 |
am__quote = @am__quote@ |
115 | 115 |
install_sh = @install_sh@ |
116 | 116 |
|
117 |
-@USE_PTHREAD_TRUE@bin_PROGRAMS = clamdscan |
|
117 |
+@BUILD_CLAMD_TRUE@bin_PROGRAMS = clamdscan |
|
118 | 118 |
|
119 |
-@USE_PTHREAD_TRUE@clamdscan_SOURCES = \ |
|
120 |
-@USE_PTHREAD_TRUE@ options.c \ |
|
121 |
-@USE_PTHREAD_TRUE@ options.h \ |
|
122 |
-@USE_PTHREAD_TRUE@ clamdscan.c \ |
|
123 |
-@USE_PTHREAD_TRUE@ client.c \ |
|
124 |
-@USE_PTHREAD_TRUE@ client.h \ |
|
125 |
-@USE_PTHREAD_TRUE@ defaults.h |
|
119 |
+@BUILD_CLAMD_TRUE@clamdscan_SOURCES = \ |
|
120 |
+@BUILD_CLAMD_TRUE@ options.c \ |
|
121 |
+@BUILD_CLAMD_TRUE@ options.h \ |
|
122 |
+@BUILD_CLAMD_TRUE@ clamdscan.c \ |
|
123 |
+@BUILD_CLAMD_TRUE@ client.c \ |
|
124 |
+@BUILD_CLAMD_TRUE@ client.h \ |
|
125 |
+@BUILD_CLAMD_TRUE@ defaults.h |
|
126 | 126 |
|
127 | 127 |
|
128 |
-@USE_PTHREAD_TRUE@clamdscan_LDADD = ../clamscan/getopt.o ../clamscan/others.o ../clamd/cfgfile.o |
|
128 |
+@BUILD_CLAMD_TRUE@clamdscan_LDADD = ../clamscan/getopt.o ../clamscan/others.o ../clamd/cfgfile.o |
|
129 | 129 |
|
130 | 130 |
INCLUDES = -I../clamscan -I../clamd -I../libclamav |
131 | 131 |
LIBS = -L../libclamav -lclamav @FRESHCLAM_LIBS@ |
132 | 132 |
subdir = clamdscan |
133 | 133 |
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs |
134 | 134 |
CONFIG_CLEAN_FILES = |
135 |
-@USE_PTHREAD_TRUE@bin_PROGRAMS = clamdscan$(EXEEXT) |
|
136 |
-@USE_PTHREAD_FALSE@bin_PROGRAMS = |
|
135 |
+@BUILD_CLAMD_TRUE@bin_PROGRAMS = clamdscan$(EXEEXT) |
|
136 |
+@BUILD_CLAMD_FALSE@bin_PROGRAMS = |
|
137 | 137 |
PROGRAMS = $(bin_PROGRAMS) |
138 | 138 |
|
139 |
-@USE_PTHREAD_TRUE@am_clamdscan_OBJECTS = options.$(OBJEXT) \ |
|
140 |
-@USE_PTHREAD_TRUE@ clamdscan.$(OBJEXT) client.$(OBJEXT) |
|
139 |
+@BUILD_CLAMD_TRUE@am_clamdscan_OBJECTS = options.$(OBJEXT) \ |
|
140 |
+@BUILD_CLAMD_TRUE@ clamdscan.$(OBJEXT) client.$(OBJEXT) |
|
141 | 141 |
clamdscan_OBJECTS = $(am_clamdscan_OBJECTS) |
142 |
-@USE_PTHREAD_TRUE@clamdscan_DEPENDENCIES = ../clamscan/getopt.o \ |
|
143 |
-@USE_PTHREAD_TRUE@ ../clamscan/others.o ../clamd/cfgfile.o |
|
144 |
-@USE_PTHREAD_FALSE@clamdscan_DEPENDENCIES = |
|
142 |
+@BUILD_CLAMD_TRUE@clamdscan_DEPENDENCIES = ../clamscan/getopt.o \ |
|
143 |
+@BUILD_CLAMD_TRUE@ ../clamscan/others.o ../clamd/cfgfile.o |
|
144 |
+@BUILD_CLAMD_FALSE@clamdscan_DEPENDENCIES = |
|
145 | 145 |
clamdscan_LDFLAGS = |
146 | 146 |
|
147 | 147 |
DEFS = @DEFS@ |
... | ... |
@@ -9229,11 +9229,11 @@ esac |
9229 | 9229 |
|
9230 | 9230 |
|
9231 | 9231 |
if test "$have_pthreads" = "yes"; then |
9232 |
- USE_PTHREAD_TRUE= |
|
9233 |
- USE_PTHREAD_FALSE='#' |
|
9232 |
+ BUILD_CLAMD_TRUE= |
|
9233 |
+ BUILD_CLAMD_FALSE='#' |
|
9234 | 9234 |
else |
9235 |
- USE_PTHREAD_TRUE='#' |
|
9236 |
- USE_PTHREAD_FALSE= |
|
9235 |
+ BUILD_CLAMD_TRUE='#' |
|
9236 |
+ BUILD_CLAMD_FALSE= |
|
9237 | 9237 |
fi |
9238 | 9238 |
|
9239 | 9239 |
|
... | ... |
@@ -9247,7 +9247,13 @@ else |
9247 | 9247 |
fi |
9248 | 9248 |
|
9249 | 9249 |
|
9250 |
+if test "$have_pthreads" = "yes" |
|
9251 |
+then |
|
9252 |
+ cat >>confdefs.h <<\_ACEOF |
|
9253 |
+#define BUILD_CLAMD 1 |
|
9254 |
+_ACEOF |
|
9250 | 9255 |
|
9256 |
+fi |
|
9251 | 9257 |
|
9252 | 9258 |
|
9253 | 9259 |
if test "$test_clamav" = "yes" |
... | ... |
@@ -9864,10 +9870,10 @@ echo "$as_me: error: conditional \"INSTALL_CONF\" was never defined. |
9864 | 9864 |
Usually this means the macro was only invoked conditionally." >&2;} |
9865 | 9865 |
{ (exit 1); exit 1; }; } |
9866 | 9866 |
fi |
9867 |
-if test -z "${USE_PTHREAD_TRUE}" && test -z "${USE_PTHREAD_FALSE}"; then |
|
9868 |
- { { echo "$as_me:$LINENO: error: conditional \"USE_PTHREAD\" was never defined. |
|
9867 |
+if test -z "${BUILD_CLAMD_TRUE}" && test -z "${BUILD_CLAMD_FALSE}"; then |
|
9868 |
+ { { echo "$as_me:$LINENO: error: conditional \"BUILD_CLAMD\" was never defined. |
|
9869 | 9869 |
Usually this means the macro was only invoked conditionally." >&5 |
9870 |
-echo "$as_me: error: conditional \"USE_PTHREAD\" was never defined. |
|
9870 |
+echo "$as_me: error: conditional \"BUILD_CLAMD\" was never defined. |
|
9871 | 9871 |
Usually this means the macro was only invoked conditionally." >&2;} |
9872 | 9872 |
{ (exit 1); exit 1; }; } |
9873 | 9873 |
fi |
... | ... |
@@ -10429,8 +10435,8 @@ s,@LIBCLAMAV_LIBS@,$LIBCLAMAV_LIBS,;t t |
10429 | 10429 |
s,@CLAMD_LIBS@,$CLAMD_LIBS,;t t |
10430 | 10430 |
s,@FRESHCLAM_LIBS@,$FRESHCLAM_LIBS,;t t |
10431 | 10431 |
s,@TH_SAFE@,$TH_SAFE,;t t |
10432 |
-s,@USE_PTHREAD_TRUE@,$USE_PTHREAD_TRUE,;t t |
|
10433 |
-s,@USE_PTHREAD_FALSE@,$USE_PTHREAD_FALSE,;t t |
|
10432 |
+s,@BUILD_CLAMD_TRUE@,$BUILD_CLAMD_TRUE,;t t |
|
10433 |
+s,@BUILD_CLAMD_FALSE@,$BUILD_CLAMD_FALSE,;t t |
|
10434 | 10434 |
s,@HAVE_MILTER_TRUE@,$HAVE_MILTER_TRUE,;t t |
10435 | 10435 |
s,@HAVE_MILTER_FALSE@,$HAVE_MILTER_FALSE,;t t |
10436 | 10436 |
s,@GETENT@,$GETENT,;t t |
... | ... |
@@ -320,10 +320,13 @@ AC_SUBST(CLAMD_LIBS) |
320 | 320 |
AC_SUBST(FRESHCLAM_LIBS) |
321 | 321 |
AC_SUBST(TH_SAFE) |
322 | 322 |
|
323 |
-AM_CONDITIONAL(USE_PTHREAD, test "$have_pthreads" = "yes") |
|
323 |
+AM_CONDITIONAL(BUILD_CLAMD, test "$have_pthreads" = "yes") |
|
324 | 324 |
AM_CONDITIONAL(HAVE_MILTER, test "$have_milter" = "yes") |
325 | 325 |
|
326 |
- |
|
326 |
+if test "$have_pthreads" = "yes" |
|
327 |
+then |
|
328 |
+ AC_DEFINE(BUILD_CLAMD) |
|
329 |
+fi |
|
327 | 330 |
|
328 | 331 |
dnl Check for clamav in /etc/passwd |
329 | 332 |
|
330 | 333 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,478 @@ |
0 |
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
|
1 |
+<html> |
|
2 |
+<head> |
|
3 |
+<title>Antivirus para Sendmail con clam</title> |
|
4 |
+</head> |
|
5 |
+<body> |
|
6 |
+<h1 align="center">Antivirus para servidor de correo Sendmail con ClamAv</h1> |
|
7 |
+<hr align="center" size="5" width="95%"> |
|
8 |
+<br> |
|
9 | ||
10 |
+de virus para Sendmail, utilizando para esto el mejor antivirus del software libre "clamAv." |
|
11 |
+</p> |
|
12 |
+<a name="contenido"> |
|
13 | ||
14 |
+<ol> |
|
15 |
+ <a href="#clamav"> |
|
16 | ||
17 |
+ <br> |
|
18 |
+ <a href="#milter"> |
|
19 |
+ <li>- Instalacion del programa de enlace entre el antivirus y el servidor de correo sendmail</a></li> |
|
20 |
+ <br> |
|
21 |
+ <a href="#sendmail"> |
|
22 | ||
23 |
+ <br> |
|
24 |
+ <a href="#pruebas"> |
|
25 |
+ <li>- Pruebas del sistema</a></li> |
|
26 |
+ <br> |
|
27 |
+</ol> |
|
28 |
+ |
|
29 |
+ |
|
30 |
+ |
|
31 | ||
32 |
+<hr align="center" size="3" width="85%"> |
|
33 | ||
34 |
+<br> |
|
35 |
+<p>Vamos a instalarlo desde las fuentes, por lo tanto debemos descargar dichas fuentes |
|
36 | ||
37 |
+de <a href="http://download.sourceforge.net/clamav/">stable versions</a>(versiones estables). |
|
38 |
+</p> |
|
39 |
+ |
|
40 | ||
41 | ||
42 |
+ |
|
43 | ||
44 | ||
45 | ||
46 |
+descargar y descomprimir.</p> |
|
47 |
+ |
|
48 |
+ |
|
49 |
+<br><br><br> |
|
50 |
+ |
|
51 | ||
52 |
+ |
|
53 | ||
54 |
+<br> |
|
55 |
+<ul> |
|
56 |
+<li>groupadd clamav</li> |
|
57 |
+<li>useradd -g clamav -s /bin/false -c "Clam AntiVirus" clamav</li> |
|
58 |
+</ul> |
|
59 |
+<br> |
|
60 | ||
61 |
+<ul> |
|
62 |
+<li>Descomprimir las fuentes: <em>tar zxpvf clamav-x.yz.tar.gz</em></li><br> |
|
63 | ||
64 |
+<em>./configure --sysconfdir=/etc</em></li> |
|
65 |
+<li><em>make</em></li> |
|
66 |
+<li><em>su -c 'make install'</em></li> |
|
67 |
+</ul> |
|
68 |
+Listo!! con eso tenemos instalado el clam.</p> |
|
69 |
+ |
|
70 |
+<h4>Prueba:</h4> |
|
71 |
+ |
|
72 |
+<p>Para probarlo ejecutemos una busqueda de virus a traves del directorio de las fuentes: |
|
73 |
+<br><br> |
|
74 |
+<em>clamscan -r -l scan.txt /usr/src/clamav-0.60/</em> |
|
75 |
+<br><br> |
|
76 | ||
77 |
+<em>--------------------------------------<br> |
|
78 |
+Scan started: Thu Oct 2 18:42:28 2003<br> |
|
79 |
+<br> |
|
80 |
+/usr/src/clamav-0.60//test/test1: ClamAV-Test-Signature FOUND<br> |
|
81 |
+/usr/src/clamav-0.60//test/test1.bz2: ClamAV-Test-Signature FOUND<br> |
|
82 |
+/usr/src/clamav-0.60//test/test2.zip: ClamAV-Test-Signature FOUND<br> |
|
83 |
+/usr/src/clamav-0.60//test/test3.rar: ClamAV-Test-Signature FOUND<br> |
|
84 |
+/usr/src/clamav-0.60//test/test2.badext: ClamAV-Test-Signature FOUND<br> |
|
85 |
+<br> |
|
86 |
+-- summary --<br> |
|
87 |
+Known viruses: 7846<br> |
|
88 |
+Scanned directories: 38<br> |
|
89 |
+Scanned files: 377<br> |
|
90 |
+Infected files: 5<br> |
|
91 |
+Data scanned: 6.19 Mb<br> |
|
92 |
+I/O buffer size: 131072 bytes<br> |
|
93 |
+Time: 9.945 sec (0 m 9 s)<br> |
|
94 |
+<br><br> |
|
95 |
+</em> |
|
96 |
+<br> |
|
97 |
+</p> |
|
98 |
+ |
|
99 |
+<p> |
|
100 |
+Si vamos a usar clam em modo demonio devemos editar /etc/clamav.conf, mas informacion:<br> |
|
101 |
+<em>man 5 clamav.conf</em><br> |
|
102 |
+<br> |
|
103 |
+Mecesitaremos que corra como demonio si vamos a usar clamav-milter.<br> |
|
104 |
+</p> |
|
105 |
+ |
|
106 |
+<a href="#contenido">Volver</a> |
|
107 |
+ |
|
108 |
+ |
|
109 |
+ |
|
110 | ||
111 |
+<hr align="center" size="3" width="85%"> |
|
112 |
+ |
|
113 |
+<h3><a name="milter">2.- Instalacion del programa de enlace entre |
|
114 |
+el antivirus y el servidor de correo sendmail</h3> |
|
115 |
+<br> |
|
116 |
+<p>Ahora que clam esta funcionando correctamente, procedemos a instalar el software |
|
117 | ||
118 |
+Tenemos varias opciones:<br> |
|
119 |
+<br> |
|
120 |
+<ul> |
|
121 |
+<a href="#clamav-milter"> |
|
122 | ||
123 | ||
124 |
+<br> |
|
125 |
+<a href="#nextg"> |
|
126 | ||
127 |
+amavis-perl/amavisd, desarrollado por Hilko Bengen</li> |
|
128 |
+<br> |
|
129 |
+<a href="#amavisnew"> |
|
130 | ||
131 |
+<br> |
|
132 |
+</ul> |
|
133 |
+</p> |
|
134 |
+ |
|
135 |
+ |
|
136 |
+<strong>Nota sobre milter y sendmail:</strong><br> |
|
137 |
+<br> |
|
138 |
+<p> |
|
139 | ||
140 |
+<br> Estos archivos de desarrollo |
|
141 |
+vienen con sendmail, pero sendmail debe estar compilado con soporte para milter.<br> |
|
142 | ||
143 |
+<br> |
|
144 |
+En caso de que sendmail lo construyamos nosotros mismos debemos crear un archivo <em>site.config.m4</em> |
|
145 |
+ que contenga :<br><br> |
|
146 |
+ <em>APPENDDEF(`conf_sendmail_ENVDEF', `-DMILTER')</em> |
|
147 |
+ <br><br> |
|
148 |
+Y dicho archivo debe ir en: <em> ~/sendmail-x.xx.x/devtools/Site</em> |
|
149 |
+<br><br> |
|
150 |
+Los archivos de desarrollo tambien pueden existir como paquetes en rpm o dev, para |
|
151 |
+encontrar paquetes rpm podemos dar un vistazo en: <br> |
|
152 |
+<a href="http://rpmfind.net">http://rpmfind.net</a> buscando sendmail-devel.<br> |
|
153 |
+<br> |
|
154 |
+Si usamos Debian tan facil como:<br> |
|
155 |
+<em>apt-cache search libmilter</em><br> |
|
156 |
+<br> |
|
157 |
+Y sabremos que instalar. |
|
158 |
+ <p> |
|
159 |
+ <!--SUBSECCIONES DE MILTER------------------------------------------- --> |
|
160 |
+ |
|
161 |
+<a name="clamav-milter"> |
|
162 |
+<p> |
|
163 |
+<strong>Clamav-milter:</strong><br><br> |
|
164 | ||
165 |
+ para usarlo necesitamos reconfigurar ClamAv con:<br> |
|
166 |
+<br> |
|
167 |
+<em>./configure --enable-milter</em><br> |
|
168 |
+<br> |
|
169 |
+ |
|
170 |
+Ok, vamos al directorio de las fuentes de ClamAv. |
|
171 |
+ |
|
172 |
+<br> |
|
173 |
+<em>cd ~/lamav-x.yz/</em><br> |
|
174 |
+<br> |
|
175 |
+Y ejecutamos:<br> |
|
176 |
+<br> |
|
177 |
+<em>./configure --enable-milter --sysconfdir=/etc </em><br> |
|
178 |
+<br> |
|
179 |
+<em>make</em><br> |
|
180 |
+<br> |
|
181 |
+<em>make install</em><br> |
|
182 |
+<br> |
|
183 | ||
184 | ||
185 | ||
186 |
+<br> |
|
187 |
+<br> |
|
188 |
+Ya esta listo el milter, ahora vayamos a configurar <a href="#sendmail-clamav-milter">sendmail para clamav-milter.</a><br> |
|
189 |
+<br> |
|
190 |
+ |
|
191 |
+<!-- ----------------------------------------------------------------- --> |
|
192 |
+ |
|
193 |
+<a name="nextg"> |
|
194 |
+<p><strong>AMaViS - "Next Generation":</strong><br><br> |
|
195 |
+Lo podemos descargar desde :<br> |
|
196 |
+<br> |
|
197 |
+<a href="http://sourceforge.net/projects/amavis">http://sourceforge.net/projects/amavis</a><br> |
|
198 |
+<br> |
|
199 |
+Los descomprimimos: <em>tar zxpvf amavis-ng_0.1.6.4.orig.tar.gz</em><br> |
|
200 |
+<br> |
|
201 | ||
202 |
+<br> |
|
203 |
+<em>make amavis-ng.info</em><br> |
|
204 |
+<br> |
|
205 |
+<br> |
|
206 |
+O si tenemos instalado texi2html:<br> |
|
207 |
+<br> |
|
208 |
+<em>texi2html amavis-ng.texi</em><br> |
|
209 |
+<br> |
|
210 | ||
211 |
+<br> |
|
212 |
+<br><br> |
|
213 |
+ |
|
214 |
+<br><strong>Requisitos para amavis-ng:</strong><br> |
|
215 |
+<br> |
|
216 |
+Modulos Perl:<br> |
|
217 |
+ |
|
218 |
+<ul> |
|
219 |
+<li>File::MMagic</li> |
|
220 |
+<li>Config::IniFiles</li> |
|
221 |
+<li>MIME::Tools</li> |
|
222 |
+</ul> |
|
223 |
+Si se tiene instalado el modulo CPAN la cosa es tan facil como:<br> |
|
224 |
+<br> |
|
225 |
+<em>perl -MCPAN -e shell</em><br> |
|
226 |
+<br> |
|
227 |
+E irle indicando uno a uno:<br> |
|
228 |
+<br> |
|
229 |
+<em>install File::MMagic</em><br> |
|
230 |
+<br> |
|
231 |
+etc...<br> |
|
232 |
+<br> |
|
233 |
+</p> |
|
234 |
+ |
|
235 |
+<p> |
|
236 |
+<strong>Recomendados pero no indispensables:</strong><br> |
|
237 |
+<br> |
|
238 |
+Modulos perl:<br> |
|
239 |
+<br> |
|
240 |
+<ul> |
|
241 |
+<li>Convert::TNEF</li> |
|
242 |
+<li>Compress::Zlib</li> |
|
243 |
+<li>Archive::Tar</li> |
|
244 |
+<li>Archive::Zip</li> |
|
245 |
+</ul> |
|
246 |
+<br> |
|
247 |
+<br> |
|
248 | ||
249 |
+<br> |
|
250 |
+<ul> |
|
251 |
+<li>unrar</li> |
|
252 |
+<li>Zoo</li> |
|
253 |
+<li>Unzoo</li> |
|
254 |
+<li>nomarch</li> |
|
255 |
+<li>lha</li> |
|
256 |
+<li>unarj</li> |
|
257 |
+<li>zcat</li> |
|
258 |
+<li>bunzip2</li> |
|
259 |
+</ul> |
|
260 |
+<br> |
|
261 |
+Para verificar si los tenemos ya instalados:<br> |
|
262 |
+<br> |
|
263 |
+<em>-rpm -q paquete o -dpkg -s paquete, yast, linuxconf, etc.</em><br> |
|
264 |
+<br> |
|
265 |
+<br> |
|
266 |
+Para instalar:<br> |
|
267 |
+<br> |
|
268 |
+<em>-rpm -i paquete o -dpkg -i paquete, yast, linuxconf, etc.</em><br> |
|
269 |
+<br> |
|
270 |
+</p> |
|
271 |
+ |
|
272 |
+<strong>Instalando amavis-ng:</strong><br> |
|
273 |
+<br> |
|
274 |
+<em>perl Makefile.PL</em><br> |
|
275 |
+<br> |
|
276 |
+<em>make</em><br> |
|
277 |
+<br> |
|
278 |
+<em>su -c"make install"</em><br> |
|
279 |
+<br> |
|
280 |
+<br> |
|
281 |
+<strong>Instalando amavis-milter:</strong><br> |
|
282 |
+<br> |
|
283 | ||
284 |
+programa milter, que permitira "conectar" sendmail y amavis.<br> |
|
285 | ||
286 |
+<br> |
|
287 |
+<em>make -C amavis-milter</em><br> |
|
288 |
+<br> |
|
289 |
+<em>$ su -c "make -C amavis-milter install"</em><br> |
|
290 |
+<br> |
|
291 |
+<br> |
|
292 |
+<strong>configurando amavis-ng:</strong><br> |
|
293 |
+<br> |
|
294 |
+- Copiar el archivo de configuracion de ejemplo a <em>/etc/amavis-ng/</em>, editarlo y |
|
295 |
+modificar de la siguiente manera:<br> |
|
296 |
+<ul> |
|
297 |
+<li>mail-transfer-agent = Milter</li> |
|
298 |
+<li>virus-scanner = CLAM (o CLAMD)</li> |
|
299 |
+<li>notifiers=Sender, Recipients, Admin</li> |
|
300 |
+</ul> |
|
301 |
+<br> |
|
302 |
+Y las secciones: <br> |
|
303 |
+<em>[Milter]<br> |
|
304 |
+<br> |
|
305 |
+amavis socket = /var/run/amavis-ng/socket.amavis<br> |
|
306 |
+<br> |
|
307 |
+milter socket = /var/run/amavis-ng/socket.milter<br> |
|
308 |
+<br> |
|
309 |
+amavis-milter = /usr/sbin/amavis-milter<br> |
|
310 |
+<br> |
|
311 |
+amavis-milter pidfile = /var/run/amavis-ng/amavis-milter.pid</em><br> |
|
312 |
+<br><br> |
|
313 |
+Y <br> |
|
314 |
+<em>[CLAM]<br> |
|
315 |
+<br> |
|
316 |
+clamscan = /usr/bin/clamscan</em><br> |
|
317 |
+<br><br> |
|
318 |
+o:<br> |
|
319 |
+<em>[CLAMD]<br> |
|
320 |
+socket = localhost:3310</em> |
|
321 |
+<br><br> |
|
322 |
+<BR> |
|
323 |
+Ya esta listo el milter, ahora vayamos a configurar <a href="#sendmail-nextg">sendmail para amavis-ng.</a><br> |
|
324 |
+<br> |
|
325 |
+ |
|
326 |
+<!-- --------------------------------------------------------------------------- --> |
|
327 |
+<a name="amavisnew"> |
|
328 |
+<p> |
|
329 |
+<p><strong>AMaViS - New:</strong><br><br> |
|
330 | ||
331 |
+ |
|
332 |
+</p> |
|
333 |
+ |
|
334 |
+ |
|
335 |
+<a href="#contenido">Volver</a> |
|
336 |
+ |
|
337 |
+ |
|
338 |
+ |
|
339 |
+<hr align="center" size="3" width="85%"> |
|
340 | ||
341 |
+<a name="sendmail"> |
|
342 | ||
343 |
+ |
|
344 |
+<a name="sendmail-clamav-milter"> |
|
345 |
+<strong>Sendmail y clamav-milter:</strong></a> |
|
346 |
+<br> |
|
347 |
+<br> |
|
348 |
+Las siguientes instrucciones fueron tomasdas del archivo INSTALL de las fuentes:<br> |
|
349 |
+<br> |
|
350 |
+Agregar a /etc/mail/sendmail.mc:<br> |
|
351 |
+<br> |
|
352 |
+<em>INPUT_MAIL_FILTER(`clamav', `S=local:/var/run/clamav.sock, F=, T=S:4m;R:4m')dnl<br> |
|
353 |
+ define(`confINPUT_MAIL_FILTERS', `clamav')<br></em> |
|
354 |
+<br> |
|
355 |
+<br> |
|
356 |
+No olvidemos regenerar sendmail.cf<br> |
|
357 |
+<br> |
|
358 |
+<br> |
|
359 |
+Verificar que existan en clamav.conf las siguientes entradas:<br> |
|
360 |
+<br> |
|
361 |
+<em>LocalSocket /var/run/clamd.sock<br> |
|
362 |
+SaveStreamToDisk<br></em> |
|
363 |
+<br> |
|
364 |
+<br> |
|
365 |
+Finalmente iniciar clamav-milter:<br> |
|
366 |
+<br> |
|
367 |
+<em>/usr/local/sbin/clamav-milter -blo /var/run/clamav.sock</em><br> |
|
368 |
+<br> |
|
369 |
+Y reiniciar sendmail<br> |
|
370 |
+<br> |
|
371 |
+****En el mismo directorio de las fuentes del clamav-milter viene un script <em>clamd.sh</em> |
|
372 |
+Que podemos poner en /etc/init.d/ para iniciar el clamd.****<br> |
|
373 |
+</p> |
|
374 |
+<br><br><br> |
|
375 |
+Asi que si todo ha ido bien, ya hemos concluido y es hora de hacer alguna prueba. |
|
376 |
+<br><br><br> |
|
377 |
+ |
|
378 |
+<a name="sendmail-nextg"> |
|
379 |
+<strong>Sendmail y AMaViS - "Next Generation": </strong> |
|
380 |
+<br> |
|
381 |
+<br> |
|
382 |
+Agregar lo siguiente al archvivo `sendmail.mc':<br> |
|
383 |
+<br> |
|
384 |
+<em> |
|
385 |
+define(`MILTER', 1)<br> |
|
386 |
+INPUT_MAIL_FILTER(`milter-amavis', \<br> |
|
387 |
+ `S=local:/var/run/amavis-ng/socket.milter, F=T, T=S:10m;R:10m;E:10m')</em><br> |
|
388 |
+<br><br> |
|
389 |
+Rehacer el sendmail.cf y reiniciar sendmail.<br> |
|
390 | ||
391 |
+<em> |
|
392 |
+<br> |
|
393 |
+Xmilter-amavis: local socket name /var/run/amavis-ng/socket.milter missing</em><br> |
|
394 |
+<br> |
|
395 | ||
396 |
+<br><br><br> |
|
397 |
+ |
|
398 |
+ |
|
399 |
+ <!-- -------------------------------------------------------------- --> |
|
400 |
+<a name="sendmail-amavisnew"> |
|
401 |
+<strong>sendmail y amavisd-new:</strong> |
|
402 |
+<br> |
|
403 | ||
404 |
+<br> |
|
405 |
+ |
|
406 |
+ |
|
407 |
+ |
|
408 |
+<a href="#contenido">Volver</a> |
|
409 |
+ |
|
410 |
+ |
|
411 |
+<!-- SECCION PRUEBAS----------------------------------------------------------- --> |
|
412 |
+<hr align="center" size="3" width="85%"> |
|
413 |
+ |
|
414 |
+<a name="pruebas"> |
|
415 |
+<h3>Pruebas del sistema</h3> |
|
416 |
+<p>Para probar el sistema solo hay que enviar algunos de los archivos con firmas de |
|
417 |
+viruas que vienen en las fuentes del clam, para checar si el sistema esta detectando los virus en los correos.</p> |
|
418 |
+ |
|
419 |
+<a href="#contenido">Volver</a> |
|
420 |
+ |
|
421 |
+ |
|
422 |
+ |
|
423 |
+ |
|
424 |
+ |
|
425 |
+<hr align="center" size="3" width="85%"> |
|
426 |
+ |
|
427 |
+ |
|
428 |
+ |
|
429 | ||
430 |
+<p> |
|
431 | ||
432 | ||
433 |
+</p> |
|
434 |
+<h4>Remover antiguo clam</h4> |
|
435 |
+ |
|
436 | ||
437 |
+y simplemente hacer:<br><br> |
|
438 |
+<em>make uninstall</em> |
|
439 |
+<br><br> |
|
440 | ||
441 |
+</p> |
|
442 |
+ |
|
443 |
+ |
|
444 |
+<h4>Remover amavis perl-11</h4> |
|
445 |
+ |
|
446 | ||
447 |
+y simplemente hacer:<br><br> |
|
448 |
+<em>make uninstall</em> |
|
449 |
+<br><br> |
|
450 |
+Con lo anterior tendriamos desinstalado amavis perl-11. |
|
451 |
+<br> |
|
452 |
+ |
|
453 |
+</p> |
|
454 |
+ |
|
455 |
+<h4>Deshacer cambios para amavis-perl en Sendmail</h4> |
|
456 |
+<p>Como recordaran aquellos que usaron amavis perl, se requeria hacer algunos cambios |
|
457 | ||
458 |
+<br><br> |
|
459 |
+<ul> |
|
460 | ||
461 |
+<em> cp sendmail.cf sendmail.cf.amavisperl</em> </li> |
|
462 |
+<br> |
|
463 |
+<li>Devolver la version original de sendmail.cf :<br> |
|
464 |
+<em>cp sendmail.orig.cf sendmail.cf</em></li> |
|
465 |
+<br> |
|
466 |
+<li>Reiniciar sendmail</li> |
|
467 |
+<br> |
|
468 | ||
469 |
+a la normalidad :)</li> |
|
470 |
+</ul> |
|
471 |
+</p> |
|
472 |
+<a href="#contenido">Volver</a> |
|
473 |
+ |
|
474 |
+<hr align="center" size="3" width="85%"> |
|
475 |
+ |
|
476 |
+</body> |
|
477 |
+</html> |
... | ... |
@@ -26,10 +26,14 @@ freshclam_SOURCES = \ |
26 | 26 |
manager.h \ |
27 | 27 |
defaults.h \ |
28 | 28 |
notify.c \ |
29 |
- notify.h \ |
|
30 |
- cfgfile.c |
|
29 |
+ notify.h |
|
31 | 30 |
|
31 |
+if BUILD_CLAMD |
|
32 |
+freshclam_LDADD = ../clamscan/getopt.o ../clamscan/others.o ../clamd/cfgfile.o |
|
33 |
+else |
|
32 | 34 |
freshclam_LDADD = ../clamscan/getopt.o ../clamscan/others.o |
35 |
+endif |
|
36 |
+ |
|
33 | 37 |
|
34 | 38 |
DEFS = @DEFS@ |
35 | 39 |
INCLUDES = -I../clamscan -I../clamd -I../libclamav |
... | ... |
@@ -125,11 +125,11 @@ freshclam_SOURCES = \ |
125 | 125 |
manager.h \ |
126 | 126 |
defaults.h \ |
127 | 127 |
notify.c \ |
128 |
- notify.h \ |
|
129 |
- cfgfile.c |
|
128 |
+ notify.h |
|
130 | 129 |
|
131 | 130 |
|
132 |
-freshclam_LDADD = ../clamscan/getopt.o ../clamscan/others.o |
|
131 |
+@BUILD_CLAMD_TRUE@freshclam_LDADD = ../clamscan/getopt.o ../clamscan/others.o ../clamd/cfgfile.o |
|
132 |
+@BUILD_CLAMD_FALSE@freshclam_LDADD = ../clamscan/getopt.o ../clamscan/others.o |
|
133 | 133 |
|
134 | 134 |
DEFS = @DEFS@ |
135 | 135 |
INCLUDES = -I../clamscan -I../clamd -I../libclamav |
... | ... |
@@ -141,18 +141,20 @@ bin_PROGRAMS = freshclam$(EXEEXT) |
141 | 141 |
PROGRAMS = $(bin_PROGRAMS) |
142 | 142 |
|
143 | 143 |
am_freshclam_OBJECTS = freshclam.$(OBJEXT) options.$(OBJEXT) \ |
144 |
- manager.$(OBJEXT) notify.$(OBJEXT) cfgfile.$(OBJEXT) |
|
144 |
+ manager.$(OBJEXT) notify.$(OBJEXT) |
|
145 | 145 |
freshclam_OBJECTS = $(am_freshclam_OBJECTS) |
146 |
-freshclam_DEPENDENCIES = ../clamscan/getopt.o ../clamscan/others.o |
|
146 |
+@BUILD_CLAMD_TRUE@freshclam_DEPENDENCIES = ../clamscan/getopt.o \ |
|
147 |
+@BUILD_CLAMD_TRUE@ ../clamscan/others.o ../clamd/cfgfile.o |
|
148 |
+@BUILD_CLAMD_FALSE@freshclam_DEPENDENCIES = ../clamscan/getopt.o \ |
|
149 |
+@BUILD_CLAMD_FALSE@ ../clamscan/others.o |
|
147 | 150 |
freshclam_LDFLAGS = |
148 | 151 |
DEFAULT_INCLUDES = -I. -I$(srcdir) |
149 | 152 |
CPPFLAGS = @CPPFLAGS@ |
150 | 153 |
LDFLAGS = @LDFLAGS@ |
151 | 154 |
depcomp = $(SHELL) $(top_srcdir)/depcomp |
152 | 155 |
am__depfiles_maybe = depfiles |
153 |
-@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/cfgfile.Po ./$(DEPDIR)/freshclam.Po \ |
|
154 |
-@AMDEP_TRUE@ ./$(DEPDIR)/manager.Po ./$(DEPDIR)/notify.Po \ |
|
155 |
-@AMDEP_TRUE@ ./$(DEPDIR)/options.Po |
|
156 |
+@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/freshclam.Po ./$(DEPDIR)/manager.Po \ |
|
157 |
+@AMDEP_TRUE@ ./$(DEPDIR)/notify.Po ./$(DEPDIR)/options.Po |
|
156 | 158 |
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
157 | 159 |
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
158 | 160 |
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ |
... | ... |
@@ -211,7 +213,6 @@ mostlyclean-compile: |
211 | 211 |
distclean-compile: |
212 | 212 |
-rm -f *.tab.c |
213 | 213 |
|
214 |
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfgfile.Po@am__quote@ |
|
215 | 214 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freshclam.Po@am__quote@ |
216 | 215 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/manager.Po@am__quote@ |
217 | 216 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/notify.Po@am__quote@ |
... | ... |
@@ -522,7 +522,9 @@ void help(void) |
522 | 522 |
mprintf(" --log-verbose save additional informations\n"); |
523 | 523 |
mprintf(" --http-proxy=hostname[:port] use proxy server hostname\n"); |
524 | 524 |
mprintf(" --proxy-user=username:passwd use username/password for proxy auth\n"); |
525 |
+#ifdef BUILD_CLAMD |
|
525 | 526 |
mprintf(" --daemon-notify[=/path/clamav.conf] send RELOAD command to clamd\n"); |
527 |
+#endif |
|
526 | 528 |
mprintf(" --on-update-execute=[COMMAND] execute the COMMAND after successful update\n"); |
527 | 529 |
mprintf(" --on-error-execute=[COMMAND] execute the COMMAND if errors occured\n"); |
528 | 530 |
mprintf("\n"); |
... | ... |
@@ -291,6 +291,7 @@ int downloadmanager(const struct optstruct *opt, const char *hostname) |
291 | 291 |
mprintf("Database updated (containing in total %d signatures).\n", vir); |
292 | 292 |
logg("Database updated (containing in total %d signatures).\n", vir); |
293 | 293 |
|
294 |
+#ifdef BUILD_CLAMD |
|
294 | 295 |
if(optl(opt, "daemon-notify")) { |
295 | 296 |
const char *clamav_conf = getargl(opt, "daemon-notify"); |
296 | 297 |
if(!clamav_conf) |
... | ... |
@@ -298,6 +299,7 @@ int downloadmanager(const struct optstruct *opt, const char *hostname) |
298 | 298 |
|
299 | 299 |
notify(clamav_conf); |
300 | 300 |
} |
301 |
+#endif |
|
301 | 302 |
|
302 | 303 |
if(optl(opt, "on-update-execute")) |
303 | 304 |
system(getargl(opt, "on-update-execute")); |
... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
/* |
2 |
- * Copyright (C) 2002 Tomasz Kojm <zolw@konarski.edu.pl> |
|
2 |
+ * Copyright (C) 2002, 2003 Tomasz Kojm <zolw@konarski.edu.pl> |
|
3 | 3 |
* |
4 | 4 |
* This program is free software; you can redistribute it and/or modify |
5 | 5 |
* it under the terms of the GNU General Public License as published by |
... | ... |
@@ -16,6 +16,8 @@ |
16 | 16 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
17 | 17 |
*/ |
18 | 18 |
|
19 |
+#ifdef BUILD_CLAMD |
|
20 |
+ |
|
19 | 21 |
#include <stdio.h> |
20 | 22 |
#include <unistd.h> |
21 | 23 |
#include <sys/types.h> |
... | ... |
@@ -109,3 +111,5 @@ int notify(const char *cfgfile) |
109 | 109 |
logg("Clamd successfully notified about the update.\n"); |
110 | 110 |
return 0; |
111 | 111 |
} |
112 |
+ |
|
113 |
+#endif |
... | ... |
@@ -2,7 +2,7 @@ |
2 | 2 |
* Author: |
3 | 3 |
* Guido Draheim <guidod@gmx.de> |
4 | 4 |
* |
5 |
- * Copyright (c) 2001,2002,2003 Guido Draheim |
|
5 |
+ * Copyright (c) 2001 Guido Draheim |
|
6 | 6 |
* All rights reserved, |
7 | 7 |
* use under the restrictions of the |
8 | 8 |
* Lesser GNU General Public License |
... | ... |
@@ -53,34 +53,15 @@ |
53 | 53 |
#define _zzip_inline inline |
54 | 54 |
#endif |
55 | 55 |
#endif |
56 |
-#ifndef _zzip_size_t |
|
57 |
-#ifdef ZZIP_size_t |
|
58 |
-#define _zzip_size_t ZZIP_size_t |
|
59 |
-#else |
|
60 |
-#define _zzip_size_t size_t |
|
61 |
-#endif |
|
62 |
-#endif |
|
63 |
-#ifndef _zzip_ssize_t |
|
64 |
-#ifdef ZZIP_ssize_t |
|
65 |
-#define _zzip_ssize_t ZZIP_ssize_t |
|
66 |
-#else |
|
67 |
-#define _zzip_ssize_t ssize_t |
|
68 |
-#endif |
|
69 |
-#endif |
|
70 | 56 |
|
71 | 57 |
/* whether this library shall use a 64bit off_t largefile variant in 64on32: */ |
72 | 58 |
/* (some exported names must be renamed to avoid bad calls after linking) */ |
73 |
-#if defined ZZIP_LARGEFILE_SENSITIVE |
|
74 |
-# if _FILE_OFFSET_BITS+0 == 64 |
|
75 |
-# define ZZIP_LARGEFILE_RENAME |
|
76 |
-# elif defined _LARGE_FILES /* used on older AIX to get at 64bit off_t */ |
|
77 |
-# define ZZIP_LARGEFILE_RENAME |
|
78 |
-# elif defined _ZZIP_LARGEFILE /* or simply use this one for zzip64 runs */ |
|
79 |
-# define ZZIP_LARGEFILE_RENAME |
|
80 |
-# endif |
|
59 |
+#if defined ZZIP_LARGEFILE_SENSITIVE && _FILE_OFFSET_BITS+0 == 64 |
|
60 |
+#define ZZIP_LARGEFILE_RENAME |
|
61 |
+#elif defined _LARGE_FILES /* on AIX */ |
|
62 |
+#define ZZIP_LARGEFILE_RENAME |
|
81 | 63 |
#endif |
82 |
- |
|
83 |
-/* if the environment did not setup these for 64bit off_t largefile... */ |
|
64 |
+/* if some were forgotten but required to have 64bit off_t largefile.. */ |
|
84 | 65 |
#ifdef ZZIP_LARGEFILE_RENAME |
85 | 66 |
# ifndef _FILE_OFFSET_BITS |
86 | 67 |
# ifdef ZZIP__FILE_OFFSET_BITS /* == 64 */ |
... | ... |
@@ -89,12 +70,7 @@ |
89 | 89 |
# endif |
90 | 90 |
# ifndef _LARGE_FILES |
91 | 91 |
# ifdef ZZIP__LARGE_FILES /* == 1 */ |
92 |
-# define _LARGE_FILES ZZIP__LARGE_FILES |
|
93 |
-# endif |
|
94 |
-# endif |
|
95 |
-# ifndef _LARGEFILE_SOURCE |
|
96 |
-# ifdef ZZIP__LARGEFILE_SOURCE /* == 1 */ |
|
97 |
-# define _LARGEFILE_SOURCE ZZIP__LARGEFILE_SOURCE |
|
92 |
+# define _LARGE_FILES 1 |
|
98 | 93 |
# endif |
99 | 94 |
# endif |
100 | 95 |
#endif |
... | ... |
@@ -165,11 +141,6 @@ |
165 | 165 |
#define __attribute__(X) |
166 | 166 |
#endif |
167 | 167 |
|
168 |
-#if defined ZZIP_EXPORTS || defined ZZIPLIB_EXPORTS |
|
169 |
-# undef ZZIP_DLL |
|
170 |
-#define ZZIP_DLL 1 |
|
171 |
-#endif |
|
172 |
- |
|
173 | 168 |
/* based on zconf.h : */ |
174 | 169 |
/* compile with -DZZIP_DLL for Windows DLL support */ |
175 | 170 |
#if defined ZZIP_DLL |
... | ... |
@@ -1,3 +1,4 @@ |
1 |
+#define USE_DIRENT 0 |
|
1 | 2 |
/* |
2 | 3 |
* Author: |
3 | 4 |
* Guido Draheim <guidod@gmx.de> |
... | ... |
@@ -23,8 +24,6 @@ |
23 | 23 |
#include <stdio.h> |
24 | 24 |
#endif |
25 | 25 |
|
26 |
-//#include "__dirent.h" |
|
27 |
- |
|
28 | 26 |
#ifndef offsetof |
29 | 27 |
#pragma warning had to DEFINE offsetof as it was not in stddef.h |
30 | 28 |
#define offsetof(T,M) ((unsigned)(& ((T*)0)->M)) |
... | ... |
@@ -51,13 +50,11 @@ zzip_rewinddir(ZZIP_DIR * dir) |
51 | 51 |
{ |
52 | 52 |
if (! dir) return; |
53 | 53 |
|
54 |
- /* |
|
55 | 54 |
if (USE_DIRENT && dir->realdir) |
56 | 55 |
{ |
57 | 56 |
_zzip_rewinddir(dir->realdir); |
58 | 57 |
return; |
59 | 58 |
} |
60 |
- */ |
|
61 | 59 |
|
62 | 60 |
if (dir->hdr0) |
63 | 61 |
dir->hdr = dir->hdr0; |
... | ... |
@@ -121,12 +118,11 @@ zzip_readdir(ZZIP_DIR * dir) |
121 | 121 |
{ |
122 | 122 |
if (! dir) { errno=EBADF; return 0; } |
123 | 123 |
|
124 |
- /* |
|
125 | 124 |
if (USE_DIRENT && dir->realdir) |
126 | 125 |
{ |
127 | 126 |
if (! real_readdir(dir)) |
128 | 127 |
return 0; |
129 |
- }else */ |
|
128 |
+ }else |
|
130 | 129 |
{ |
131 | 130 |
if (! dir->hdr) return 0; |
132 | 131 |
|
... | ... |
@@ -151,10 +147,10 @@ zzip_telldir(ZZIP_DIR* dir) |
151 | 151 |
{ |
152 | 152 |
if (! dir) { errno=EBADF; return -1; } |
153 | 153 |
|
154 |
- /* if (USE_DIRENT && dir->realdir) |
|
154 |
+ if (USE_DIRENT && dir->realdir) |
|
155 | 155 |
{ |
156 | 156 |
return _zzip_telldir(dir->realdir); |
157 |
- }else*/ |
|
157 |
+ }else |
|
158 | 158 |
{ |
159 | 159 |
return ((zzip_off_t) ((char*) dir->hdr - (char*) dir->hdr0)); |
160 | 160 |
} |
... | ... |
@@ -168,10 +164,10 @@ zzip_seekdir(ZZIP_DIR* dir, zzip_off_t offset) |
168 | 168 |
{ |
169 | 169 |
if (! dir) return; |
170 | 170 |
|
171 |
- /*if (USE_DIRENT && dir->realdir) |
|
171 |
+ if (USE_DIRENT && dir->realdir) |
|
172 | 172 |
{ |
173 | 173 |
_zzip_seekdir(dir->realdir, offset); |
174 |
- }else*/ |
|
174 |
+ }else |
|
175 | 175 |
{ |
176 | 176 |
dir->hdr = (struct zzip_dir_hdr*) |
177 | 177 |
(dir->hdr0 ? (char*) dir->hdr0 + (size_t) offset : 0); |
... | ... |
@@ -233,23 +229,6 @@ zzip_opendir_ext_io(zzip_char_t* filename, int o_modes, |
233 | 233 |
# ifdef ZZIP_HAVE_SYS_STAT_H |
234 | 234 |
if (stat(filename, &st) >= 0 && S_ISDIR(st.st_mode) |
235 | 235 |
){ |
236 |
- /* if (USE_DIRENT) |
|
237 |
- { |
|
238 |
- _zzip_DIR* realdir = _zzip_opendir(filename); |
|
239 |
- if (realdir) |
|
240 |
- { |
|
241 |
- if (! (dir = (ZZIP_DIR *)calloc(1, sizeof (*dir)))) |
|
242 |
- { |
|
243 |
- _zzip_closedir(realdir); |
|
244 |
- return 0; |
|
245 |
- }else |
|
246 |
- { |
|
247 |
- dir->realdir = realdir; |
|
248 |
- dir->realname = strdup(filename); |
|
249 |
- return dir; |
|
250 |
- } |
|
251 |
- } |
|
252 |
- } */ |
|
253 | 236 |
return 0; |
254 | 237 |
} |
255 | 238 |
# endif /* HAVE_SYS_STAT_H */ |
... | ... |
@@ -274,13 +253,13 @@ zzip_closedir(ZZIP_DIR* dir) |
274 | 274 |
{ |
275 | 275 |
if (! dir) { errno = EBADF; return -1; } |
276 | 276 |
|
277 |
- /*if (USE_DIRENT && dir->realdir) |
|
277 |
+ if (USE_DIRENT && dir->realdir) |
|
278 | 278 |
{ |
279 | 279 |
_zzip_closedir(dir->realdir); |
280 | 280 |
free(dir->realname); |
281 | 281 |
free(dir); |
282 | 282 |
return 0; |
283 |
- }else*/ |
|
283 |
+ }else |
|
284 | 284 |
{ |
285 | 285 |
zzip_dir_close(dir); |
286 | 286 |
return 0; |
... | ... |
@@ -16,7 +16,6 @@ |
16 | 16 |
|
17 | 17 |
#include "strc.h" |
18 | 18 |
|
19 |
-#include <sys/types.h> /* njh@bandsman.co.uk: for icc7.0 */ |
|
20 | 19 |
#include <string.h> |
21 | 20 |
#include <sys/stat.h> |
22 | 21 |
#include <errno.h> |
... | ... |
@@ -24,7 +23,6 @@ |
24 | 24 |
#include <ctype.h> |
25 | 25 |
|
26 | 26 |
#include <zzipformat.h> |
27 |
-//#include "__debug.h" |
|
28 | 27 |
|
29 | 28 |
#if 0 |
30 | 29 |
# if defined ZZIP_HAVE_IO_H |
... | ... |
@@ -170,9 +168,6 @@ zzip_file_open(ZZIP_DIR * dir, zzip_char_t* name, int o_mode) |
170 | 170 |
if (n) hdr_name = n + 1; |
171 | 171 |
} |
172 | 172 |
|
173 |
- //HINT4("name='%s', compr=%d, size=%d\n", |
|
174 |
- // hdr->d_name, hdr->d_compr, hdr->d_usize); |
|
175 |
- |
|
176 | 173 |
if (!cmp(hdr_name, name)) |
177 | 174 |
{ |
178 | 175 |
switch (hdr->d_compr) |
... | ... |
@@ -223,11 +218,11 @@ zzip_file_open(ZZIP_DIR * dir, zzip_char_t* name, int o_mode) |
223 | 223 |
|
224 | 224 |
{ /* skip local header - should test tons of other info, |
225 | 225 |
* but trust that those are correct */ |
226 |
- zzip_ssize_t dataoff; |
|
226 |
+ int dataoff; |
|
227 | 227 |
struct zzip_file_header * p = (void*) fp->buf32k; |
228 | 228 |
|
229 | 229 |
dataoff = dir->io->read(dir->fd, (void*)p, sizeof(*p)); |
230 |
- if (dataoff < (zzip_ssize_t)sizeof(*p)) |
|
230 |
+ if (dataoff < (int) sizeof(*p)) |
|
231 | 231 |
{ err = ZZIP_DIR_READ; goto error; } |
232 | 232 |
if (! ZZIP_FILE_HEADER_CHECKMAGIC(p)) /* PK\3\4 */ |
233 | 233 |
{ err = ZZIP_CORRUPTED; goto error; } |
... | ... |
@@ -324,12 +319,12 @@ zzip_close(ZZIP_FILE* fp) |
324 | 324 |
* required just that but the latest zlib would work just fine with |
325 | 325 |
* a smaller buffer. |
326 | 326 |
*/ |
327 |
-zzip_ssize_t |
|
328 |
-zzip_file_read(ZZIP_FILE * fp, char * buf, zzip_size_t len) |
|
327 |
+int |
|
328 |
+zzip_file_read(ZZIP_FILE * fp, char * buf, int len) |
|
329 | 329 |
{ |
330 | 330 |
ZZIP_DIR * dir; |
331 |
- zzip_size_t l; |
|
332 |
- zzip_ssize_t rv; |
|
331 |
+ int l; |
|
332 |
+ int rv; |
|
333 | 333 |
|
334 | 334 |
if (! fp || ! fp->dir) return 0; |
335 | 335 |
|
... | ... |
@@ -359,15 +354,14 @@ zzip_file_read(ZZIP_FILE * fp, char * buf, zzip_size_t len) |
359 | 359 |
|
360 | 360 |
do { |
361 | 361 |
int err; |
362 |
- zzip_size_t startlen; |
|
362 |
+ int startlen; |
|
363 | 363 |
|
364 | 364 |
if (fp->crestlen > 0 && fp->d_stream.avail_in == 0) |
365 | 365 |
{ |
366 |
- zzip_size_t cl = ( fp->crestlen < ZZIP_32K ? |
|
367 |
- fp->crestlen : ZZIP_32K ); |
|
368 |
- /* zzip_size_t cl = fp->crestlen > 128 ? 128 : fp->crestlen; */ |
|
366 |
+ int cl = fp->crestlen > ZZIP_32K ? ZZIP_32K : fp->crestlen; |
|
367 |
+ /* int cl = fp->crestlen > 128? 128: fp->crestlen; */ |
|
369 | 368 |
|
370 |
- zzip_ssize_t i = fp->io->read(dir->fd, fp->buf32k, cl); |
|
369 |
+ int i = fp->io->read(dir->fd, fp->buf32k, cl); |
|
371 | 370 |
if (i <= 0) |
372 | 371 |
{ |
373 | 372 |
dir->errcode = ZZIP_DIR_READ; /* or ZZIP_DIR_READ_EOF ? */ |
... | ... |
@@ -414,14 +408,14 @@ zzip_file_read(ZZIP_FILE * fp, char * buf, zzip_size_t len) |
414 | 414 |
* perform a normal => read(2)-call, otherwise => zzip_file_read is called |
415 | 415 |
* to decompress the data stream and any error is mapped to => errno(3). |
416 | 416 |
*/ |
417 |
-zzip_ssize_t |
|
418 |
-zzip_read(ZZIP_FILE * fp, char * buf, zzip_size_t len) |
|
417 |
+int |
|
418 |
+zzip_read(ZZIP_FILE * fp, char * buf, int len) |
|
419 | 419 |
{ |
420 | 420 |
if (! fp) return 0; |
421 | 421 |
if (! fp->dir) |
422 | 422 |
{ return fp->io->read(fp->fd, buf, len); } /* stat fd */ |
423 | 423 |
else |
424 |
- { register zzip_ssize_t v; |
|
424 |
+ { register int v; |
|
425 | 425 |
v = zzip_file_read(fp, buf, len); |
426 | 426 |
if (v == -1) { errno = zzip_errno(fp->dir->errcode); } |
427 | 427 |
return v; |
... | ... |
@@ -430,8 +424,8 @@ zzip_read(ZZIP_FILE * fp, char * buf, zzip_size_t len) |
430 | 430 |
|
431 | 431 |
/** => zzip_read |
432 | 432 |
*/ |
433 |
-zzip_size_t |
|
434 |
-zzip_fread(void *ptr, zzip_size_t size, zzip_size_t nmemb, ZZIP_FILE *file) |
|
433 |
+int |
|
434 |
+zzip_fread(void *ptr, int size, int nmemb, ZZIP_FILE *file) |
|
435 | 435 |
{ |
436 | 436 |
if (! size) size=1; |
437 | 437 |
return zzip_read (file, ptr, size*nmemb)/size; |
... | ... |
@@ -716,7 +710,7 @@ zzip_open_shared_io (ZZIP_FILE* stream, |
716 | 716 |
/* see if we can share the same zip directory */ |
717 | 717 |
if (stream && stream->dir && stream->dir->realname) |
718 | 718 |
{ |
719 |
- zzip_size_t len = strlen (stream->dir->realname); |
|
719 |
+ int len = strlen (stream->dir->realname); |
|
720 | 720 |
if (! memcmp (filename, stream->dir->realname, len) && |
721 | 721 |
filename[len] == '/' && filename[len+1]) |
722 | 722 |
{ |
... | ... |
@@ -866,10 +860,10 @@ zzip_rewind(ZZIP_FILE *fp) |
866 | 866 |
* how gzio implements it, so I'm not sure there is a better way |
867 | 867 |
* without using the internals of the algorithm. |
868 | 868 |
*/ |
869 |
-zzip_off_t |
|
870 |
-zzip_seek(ZZIP_FILE * fp, zzip_off_t offset, int whence) |
|
869 |
+int |
|
870 |
+zzip_seek(ZZIP_FILE * fp, int offset, int whence) |
|
871 | 871 |
{ |
872 |
- zzip_off_t cur_pos, rel_ofs, read_size, ofs; |
|
872 |
+ int cur_pos, rel_ofs, read_size, ofs; |
|
873 | 873 |
ZZIP_DIR *dir; |
874 | 874 |
|
875 | 875 |
if (! fp) |
... | ... |
@@ -877,7 +871,7 @@ zzip_seek(ZZIP_FILE * fp, zzip_off_t offset, int whence) |
877 | 877 |
|
878 | 878 |
if (! fp->dir) |
879 | 879 |
{ /* stat fd */ |
880 |
- return fp->io->seeks(fp->fd, offset, whence); |
|
880 |
+ return fp->io->seeks(fp->fd,offset,whence); |
|
881 | 881 |
} |
882 | 882 |
|
883 | 883 |
cur_pos = zzip_tell(fp); |
... | ... |
@@ -916,7 +910,7 @@ zzip_seek(ZZIP_FILE * fp, zzip_off_t offset, int whence) |
916 | 916 |
if (read_size < 0) /* bad offset, before beginning of file */ |
917 | 917 |
return -1; |
918 | 918 |
|
919 |
- if (read_size + cur_pos > (zzip_off_t)fp->usize) /* bad offset, past EOF */ |
|
919 |
+ if (read_size + cur_pos > fp->usize) /* bad offset, past EOF */ |
|
920 | 920 |
return -1; |
921 | 921 |
|
922 | 922 |
if (read_size == 0) /* nothing to read */ |
... | ... |
@@ -955,10 +949,10 @@ zzip_seek(ZZIP_FILE * fp, zzip_off_t offset, int whence) |
955 | 955 |
|
956 | 956 |
while (read_size > 0) |
957 | 957 |
{ |
958 |
- zzip_off_t size = ZZIP_32K; |
|
959 |
- if (read_size < size/*32K*/) size = read_size; |
|
958 |
+ int size = ZZIP_32K; |
|
959 |
+ if (read_size < ZZIP_32K) size = (int)read_size; |
|
960 | 960 |
|
961 |
- size = zzip_file_read(fp, buf, (zzip_size_t)size); |
|
961 |
+ size = zzip_file_read(fp, buf, size); |
|
962 | 962 |
if (size <= 0) { free(buf); return -1; } |
963 | 963 |
|
964 | 964 |
read_size -= size; |
... | ... |
@@ -981,7 +975,7 @@ zzip_seek(ZZIP_FILE * fp, zzip_off_t offset, int whence) |
981 | 981 |
* calculated from the amount of data left and the total uncompressed |
982 | 982 |
* size; |
983 | 983 |
*/ |
984 |
-zzip_off_t |
|
984 |
+int |
|
985 | 985 |
zzip_tell(ZZIP_FILE * fp) |
986 | 986 |
{ |
987 | 987 |
if (! fp) |
... | ... |
@@ -65,10 +65,10 @@ struct zzip_file |
65 | 65 |
struct zzip_dir* dir; |
66 | 66 |
int fd; |
67 | 67 |
int method; |
68 |
- zzip_size_t restlen; |
|
69 |
- zzip_size_t crestlen; |
|
70 |
- zzip_size_t usize; |
|
71 |
- zzip_size_t csize; |
|
68 |
+ int restlen; |
|
69 |
+ int crestlen; |
|
70 |
+ int usize; |
|
71 |
+ int csize; |
|
72 | 72 |
/* added dataoffset member - data offset from start of zipfile*/ |
73 | 73 |
zzip_off_t dataoffset; |
74 | 74 |
char* buf32k; |
... | ... |
@@ -26,11 +26,9 @@ |
26 | 26 |
|
27 | 27 |
//#include "__mmap.h" |
28 | 28 |
//#include "__debug.h" |
29 |
+// |
|
29 | 30 |
|
30 |
-#define __sizeof(X) ((zzip_ssize_t)(sizeof(X))) |
|
31 |
- |
|
32 |
-/* per default, we use a little hack to correct bad z_rootseek parts */ |
|
33 |
-#define ZZIP_CORRECT_ROOTSEEK 1 |
|
31 |
+#include "others.h" |
|
34 | 32 |
|
35 | 33 |
/* ------------------------- fetch helpers --------------------------------- */ |
36 | 34 |
|
... | ... |
@@ -44,7 +42,7 @@ uint32_t __zzip_get32(unsigned char * s) |
44 | 44 |
| ((uint32_t)s[1] << 8) | (uint32_t)s[0]; |
45 | 45 |
} |
46 | 46 |
|
47 |
-/** => __zzip_get32 |
|
47 |
+/** => __zzip_get16 |
|
48 | 48 |
* This function does the same for a 16 bit value. |
49 | 49 |
*/ |
50 | 50 |
uint16_t __zzip_get16(unsigned char * s) |
... | ... |
@@ -52,88 +50,6 @@ uint16_t __zzip_get16(unsigned char * s) |
52 | 52 |
return ((uint16_t)s[1] << 8) | (uint16_t)s[0]; |
53 | 53 |
} |
54 | 54 |
|
55 |
-/* --------------------------- internals -------------------------------- */ |
|
56 |
-/* internal functions of zziplib, avoid at all cost, changes w/o warning. |
|
57 |
- * we do export them for debugging purpose and special external tools |
|
58 |
- * which know what they do and which can adapt from version to version |
|
59 |
- */ |
|
60 |
- |
|
61 |
-int __zzip_find_disk_trailer( int fd, zzip_off_t filesize, |
|
62 |
- struct zzip_disk_trailer * trailer, |
|
63 |
- zzip_plugin_io_t io); |
|
64 |
-int __zzip_parse_root_directory( int fd, |
|
65 |
- struct zzip_disk_trailer * trailer, |
|
66 |
- struct zzip_dir_hdr ** hdr_return, |
|
67 |
- zzip_plugin_io_t io); |
|
68 |
- |
|
69 |
-_zzip_inline char* __zzip_aligned4(char* p); |
|
70 |
- |
|
71 |
-/* ------------------------ harden routines ------------------------------ */ |
|
72 |
- |
|
73 |
-#ifdef ZZIP_HARDEN |
|
74 |
-/* |
|
75 |
- * check for inconsistent values in trailer and prefer lower seek value |
|
76 |
- * - we fix values assuming the root directory was written at the end |
|
77 |
- * and it is just before the zip trailer. Therefore, ... |
|
78 |
- */ |
|
79 |
-_zzip_inline static void __fixup_rootseek( |
|
80 |
- zzip_off_t offset_of_trailer, |
|
81 |
- struct zzip_disk_trailer* trailer) |
|
82 |
-{ |
|
83 |
- if ( (zzip_off_t) ZZIP_GET32(trailer->z_rootseek) > |
|
84 |
- offset_of_trailer - (zzip_off_t) ZZIP_GET32(trailer->z_rootsize) && |
|
85 |
- offset_of_trailer > (zzip_off_t) ZZIP_GET32(trailer->z_rootsize)) |
|
86 |
- { |
|
87 |
- register zzip_off_t offset; |
|
88 |
- offset = offset_of_trailer - ZZIP_GET32(trailer->z_rootsize); |
|
89 |
- trailer->z_rootseek[0] = offset & 0xff; |
|
90 |
- trailer->z_rootseek[1] = offset >> 8 & 0xff; |
|
91 |
- trailer->z_rootseek[2] = offset >> 16 & 0xff; |
|
92 |
- trailer->z_rootseek[3] = offset >> 24 & 0xff; |
|
93 |
- //HINT2("new rootseek=%li", |
|
94 |
- // (long) ZZIP_GET32(trailer->z_rootseek)); |
|
95 |
- } |
|
96 |
-} |
|
97 |
-#define __correct_rootseek(A,B,C) |
|
98 |
- |
|
99 |
-#elif defined ZZIP_CORRECT_ROOTSEEK |
|
100 |
-/* store the seekvalue of the trailer into the "z_magic" field and with |
|
101 |
- * a 64bit off_t we overwrite z_disk/z_finaldisk as well. If you change |
|
102 |
- * anything in zziplib or dump the trailer structure then watch out that |
|
103 |
- * these are still unused, so that this code may still (ab)use those. */ |
|
104 |
-#define __fixup_rootseek(_offset_of_trailer, _trailer) \ |
|
105 |
- *(zzip_off_t*)_trailer = _offset_of_trailer; |
|
106 |
-#define __correct_rootseek( _u_rootseek, _u_rootsize, _trailer) \ |
|
107 |
- if (_u_rootseek > *(zzip_off_t*)_trailer - _u_rootsize) \ |
|
108 |
- _u_rootseek = *(zzip_off_t*)_trailer - _u_rootsize; |
|
109 |
-#else |
|
110 |
-#define __fixup_rootseek(A,B) |
|
111 |
-#define __correct_rootseek(A,B,C) |
|
112 |
-#endif |
|
113 |
- |
|
114 |
- |
|
115 |
-#ifdef DEBUG |
|
116 |
-_zzip_inline static void __debug_dir_hdr (struct zzip_dir_hdr* hdr) |
|
117 |
-{ |
|
118 |
- if (sizeof(struct zzip_dir_hdr) > sizeof(struct zzip_root_dirent)) |
|
119 |
- { WARN1("internal sizeof-mismatch may break wreakage"); } |
|
120 |
- /* the internal directory structure is never bigger than the |
|
121 |
- * external zip central directory space had been beforehand |
|
122 |
- * (as long as the following assertion holds...) |
|
123 |
- */ |
|
124 |
- |
|
125 |
- //if (((unsigned)hdr)&3) |
|
126 |
- //{ NOTE1("this machine's malloc(3) returns sth. not u32-aligned"); } |
|
127 |
- /* we assume that if this machine's malloc has returned a non-aligned |
|
128 |
- * memory block, then it is actually safe to access misaligned data, and |
|
129 |
- * since it does only affect the first hdr it should not even bring about |
|
130 |
- * too much of that cpu's speed penalty |
|
131 |
- */ |
|
132 |
-} |
|
133 |
-#else |
|
134 |
-#define __debug_dir_hdr(X) |
|
135 |
-#endif |
|
136 |
- |
|
137 | 55 |
/* -------------------------- low-level interface -------------------------- */ |
138 | 56 |
|
139 | 57 |
#if defined BUFSIZ |
... | ... |
@@ -157,13 +73,11 @@ __zzip_find_disk_trailer(int fd, zzip_off_t filesize, |
157 | 157 |
struct zzip_disk_trailer * trailer, |
158 | 158 |
zzip_plugin_io_t io) |
159 | 159 |
{ |
160 |
-/* |
|
161 | 160 |
#ifdef DEBUG |
162 |
-#define return(val) { e=val; HINT2("%s", zzip_strerror(e)); goto cleanup; } |
|
161 |
+#define return(val) { e=val; goto cleanup; } |
|
163 | 162 |
#else |
164 |
-*/ |
|
165 | 163 |
#define return(val) { e=val; goto cleanup; } |
166 |
-//#endif |
|
164 |
+#endif |
|
167 | 165 |
register int e; |
168 | 166 |
|
169 | 167 |
#ifndef _LOWSTK |
... | ... |
@@ -173,13 +87,13 @@ __zzip_find_disk_trailer(int fd, zzip_off_t filesize, |
173 | 173 |
char* buf = malloc(2*ZZIP_BUFSIZ); |
174 | 174 |
#endif |
175 | 175 |
zzip_off_t offset = 0; |
176 |
- zzip_off_t maplen = 0; /* mmap(),read(),getpagesize() use size_t !! */ |
|
176 |
+ size_t maplen = 0; |
|
177 | 177 |
char* fd_map = 0; |
178 | 178 |
|
179 | 179 |
if (!trailer) |
180 | 180 |
{ return(EINVAL); } |
181 | 181 |
|
182 |
- if (filesize < __sizeof(struct zzip_disk_trailer)) |
|
182 |
+ if (filesize < sizeof(struct zzip_disk_trailer)) |
|
183 | 183 |
{ return(ZZIP_DIR_TOO_SHORT); } |
184 | 184 |
|
185 | 185 |
if (!buf) |
... | ... |
@@ -188,7 +102,8 @@ __zzip_find_disk_trailer(int fd, zzip_off_t filesize, |
188 | 188 |
offset = filesize; /* a.k.a. old offset */ |
189 | 189 |
while(1) /* outer loop */ |
190 | 190 |
{ |
191 |
- register unsigned char* mapped; |
|
191 |
+ register unsigned char* p; |
|
192 |
+ register unsigned char* s; |
|
192 | 193 |
|
193 | 194 |
if (offset <= 0) { return(ZZIP_DIR_EDH_MISSING); } |
194 | 195 |
|
... | ... |
@@ -196,34 +111,6 @@ __zzip_find_disk_trailer(int fd, zzip_off_t filesize, |
196 | 196 |
if (filesize-offset > 64*1024) |
197 | 197 |
{ return(ZZIP_DIR_EDH_MISSING); } |
198 | 198 |
|
199 |
- /* the new offset shall overlap with the area after the old offset! */ |
|
200 |
- /*if (USE_MMAP && io->use_mmap) |
|
201 |
- { |
|
202 |
- zzip_off_t mapoff = offset; |
|
203 |
- { |
|
204 |
- zzip_off_t pagesize = _zzip_getpagesize (io->use_mmap); |
|
205 |
- if (pagesize < ZZIP_BUFSIZ) goto non_mmap; |
|
206 |
- if (mapoff == filesize && filesize > pagesize) |
|
207 |
- mapoff -= pagesize; |
|
208 |
- if (mapoff < pagesize) { |
|
209 |
- maplen = mapoff + pagesize; mapoff = 0; |
|
210 |
- } else { |
|
211 |
- mapoff -= pagesize; maplen = 2*pagesize; |
|
212 |
- if (mapoff & (pagesize-1)) { |
|
213 |
- pagesize -= mapoff & (pagesize-1); |
|
214 |
- mapoff += pagesize; |
|
215 |
- maplen -= pagesize; |
|
216 |
- } |
|
217 |
- } |
|
218 |
- if (mapoff + maplen > filesize) maplen = filesize - mapoff; |
|
219 |
- } |
|
220 |
- |
|
221 |
- fd_map = _zzip_mmap(io->use_mmap, fd, mapoff, (zzip_size_t)maplen); |
|
222 |
- if (fd_map == MAP_FAILED) goto non_mmap; |
|
223 |
- mapped = fd_map; offset = mapoff; |
|
224 |
- HINT3("mapped *%p len=%li", fd_map, (long) maplen); |
|
225 |
- } else */ { |
|
226 |
- non_mmap: |
|
227 | 199 |
fd_map = 0; /* have no mmap */ |
228 | 200 |
{ |
229 | 201 |
zzip_off_t pagesize = ZZIP_BUFSIZ; |
... | ... |
@@ -244,52 +131,50 @@ __zzip_find_disk_trailer(int fd, zzip_off_t filesize, |
244 | 244 |
|
245 | 245 |
if (io->seeks(fd, offset, SEEK_SET) < 0) |
246 | 246 |
{ return(ZZIP_DIR_SEEK); } |
247 |
- if (io->read(fd, buf, (zzip_size_t)maplen) < (zzip_ssize_t)maplen) |
|
247 |
+ if (io->read(fd, buf, maplen) < (long)maplen) |
|
248 | 248 |
{ return(ZZIP_DIR_READ); } |
249 |
- mapped = buf; /* success */ |
|
250 |
- //HINT5("offs=$%lx len=%li filesize=%li pagesize=%i", |
|
251 |
- //(long)offset, (long)maplen, (long)filesize, ZZIP_BUFSIZ); |
|
252 |
- } |
|
249 |
+ p = buf; /* success */ |
|
253 | 250 |
|
254 |
- {/* now, check for the trailer-magic, hopefully near the end of file */ |
|
255 |
- register unsigned char* end = mapped + maplen; |
|
256 |
- register unsigned char* tail; |
|
257 |
- for (tail = end-1; (tail >= mapped); tail--) |
|
258 |
- { |
|
259 |
- if ((*tail == 'P') && /* quick pre-check for trailer magic */ |
|
260 |
- end-tail >= __sizeof(*trailer)-2 && |
|
261 |
- ZZIP_DISK_TRAILER_CHECKMAGIC(tail)) |
|
262 |
- { |
|
263 |
- /* if the file-comment is not present, it happens |
|
264 |
- that the z_comment field often isn't either */ |
|
265 |
- if (end-tail >= __sizeof(*trailer)) |
|
266 |
- { |
|
267 |
- memcpy (trailer, tail, sizeof(*trailer)); |
|
268 |
- }else{ |
|
269 |
- memcpy (trailer, tail, sizeof(*trailer)-2); |
|
270 |
- trailer->z_comment[0] = 0; |
|
271 |
- trailer->z_comment[1] = 0; |
|
272 |
- } |
|
273 |
- |
|
274 |
- __fixup_rootseek (offset + tail-mapped, trailer); |
|
275 |
- { return(0); } |
|
276 |
- } |
|
277 |
- } |
|
251 |
+ |
|
252 |
+ /* now, check for the trailer-magic, hopefully near the end of file */ |
|
253 |
+ for (s = p + maplen-1; (s >= p); s--) |
|
254 |
+ { |
|
255 |
+ if (*s == 'P' |
|
256 |
+ && p+maplen-1-s > sizeof(*trailer)-2 |
|
257 |
+ && ZZIP_DISK_TRAILER_CHECKMAGIC(s)) |
|
258 |
+ { |
|
259 |
+ /* if the file-comment is not present, it happens |
|
260 |
+ that the z_comment field often isn't either */ |
|
261 |
+ if (p+maplen-1-s > sizeof(*trailer)) |
|
262 |
+ { memcpy (trailer, s, sizeof(*trailer)); } |
|
263 |
+ else |
|
264 |
+ { |
|
265 |
+ memcpy (trailer, s, sizeof(*trailer)-2); |
|
266 |
+ trailer->z_comment[0] = 0; trailer->z_comment[1] = 0; |
|
267 |
+ } |
|
268 |
+ |
|
269 |
+ /* check for inconsistent values in trailer |
|
270 |
+ (prefer lower seek value) */ |
|
271 |
+ if ( ZZIP_GET32(trailer->z_rootseek) > |
|
272 |
+ offset+s-p - ZZIP_GET32(trailer->z_rootsize) |
|
273 |
+ && offset+s-p > ZZIP_GET32(trailer->z_rootsize)) |
|
274 |
+ { |
|
275 |
+ cli_errmsg("zziplib: rootseek or length information incorrect\n"); |
|
276 |
+ offset = offset+s-p - ZZIP_GET32(trailer->z_rootsize); |
|
277 |
+ trailer->z_rootseek[0] = offset & 0xff; |
|
278 |
+ trailer->z_rootseek[1] = offset >> 8 & 0xff; |
|
279 |
+ trailer->z_rootseek[2] = offset >> 16 & 0xff; |
|
280 |
+ trailer->z_rootseek[3] = offset >> 24 & 0xff; |
|
281 |
+ /* HINT2("new rootseek=%li", |
|
282 |
+ (long) ZZIP_GET32(trailer->z_rootseek)); */ |
|
283 |
+ } |
|
284 |
+ return(0); |
|
285 |
+ } |
|
278 | 286 |
} |
279 | 287 |
|
280 |
- /*if (USE_MMAP && fd_map) |
|
281 |
- { |
|
282 |
- HINT3("unmap *%p len=%li", fd_map, (long) maplen); |
|
283 |
- _zzip_munmap(io->use_mmap, fd_map, (zzip_size_t)maplen); fd_map = 0; |
|
284 |
- }*/ |
|
285 | 288 |
} /*outer loop*/ |
286 | 289 |
|
287 | 290 |
cleanup: |
288 |
- /*if (USE_MMAP && fd_map) |
|
289 |
- { |
|
290 |
- HINT3("unmap *%p len=%li", fd_map, (long) maplen); |
|
291 |
- _zzip_munmap(io->use_mmap, fd_map, (zzip_size_t)maplen); |
|
292 |
- }*/ |
|
293 | 291 |
# ifdef _LOWSTK |
294 | 292 |
free(buf); |
295 | 293 |
# endif |
... | ... |
@@ -307,8 +192,8 @@ __zzip_find_disk_trailer(int fd, zzip_off_t filesize, |
307 | 307 |
_zzip_inline char* __zzip_aligned4(char* p) |
308 | 308 |
{ |
309 | 309 |
#define aligned4 __zzip_aligned4 |
310 |
- p += ((long)p)&1; /* warnings about truncation of a "pointer" */ |
|
311 |
- p += ((long)p)&2; /* to a "long int" may be safely ignored :) */ |
|
310 |
+ p += ((long)p)&1; |
|
311 |
+ p += ((long)p)&2; |
|
312 | 312 |
return p; |
313 | 313 |
} |
314 | 314 |
|
... | ... |
@@ -329,33 +214,34 @@ __zzip_parse_root_directory(int fd, |
329 | 329 |
struct zzip_dir_hdr * hdr0; |
330 | 330 |
uint16_t * p_reclen = 0; |
331 | 331 |
short entries; |
332 |
- long offset; /* offset from start of root directory */ |
|
333 |
- char* fd_map = 0; |
|
332 |
+ long offset, fallback_offset; |
|
333 |
+ char* fd_map = 0; |
|
334 | 334 |
int32_t fd_gap = 0; |
335 | 335 |
uint16_t u_entries = ZZIP_GET16(trailer->z_entries); |
336 | 336 |
uint32_t u_rootsize = ZZIP_GET32(trailer->z_rootsize); |
337 | 337 |
uint32_t u_rootseek = ZZIP_GET32(trailer->z_rootseek); |
338 |
- __correct_rootseek (u_rootseek, u_rootsize, trailer); |
|
339 | 338 |
|
340 | 339 |
hdr0 = (struct zzip_dir_hdr*) malloc(u_rootsize); |
341 | 340 |
if (!hdr0) |
342 | 341 |
return ZZIP_DIRSIZE; |
343 |
- hdr = hdr0; __debug_dir_hdr (hdr); |
|
342 |
+ hdr = hdr0; |
|
344 | 343 |
|
345 |
- /*if (USE_MMAP && io->use_mmap) |
|
346 |
- { |
|
347 |
- fd_gap = u_rootseek & (_zzip_getpagesize(io->use_mmap)-1) ; |
|
348 |
- HINT4(" mapseek=0x%x, maplen=%d, fd_gap=%d", |
|
349 |
- u_rootseek-fd_gap, u_rootsize+fd_gap, fd_gap); |
|
350 |
- fd_map = _zzip_mmap(io->use_mmap, |
|
351 |
- fd, u_rootseek-fd_gap, u_rootsize+fd_gap); |
|
352 |
- if (fd_map == MAP_FAILED) { |
|
353 |
- NOTE2("map failed: %s",strerror(errno)); |
|
354 |
- fd_map=0; |
|
355 |
- }else{ |
|
356 |
- HINT3("mapped *%p len=%i", fd_map, u_rootsize+fd_gap); |
|
357 |
- } |
|
358 |
- }*/ |
|
344 |
+# ifdef DEBUG |
|
345 |
+ if (sizeof(struct zzip_dir_hdr) > sizeof(struct zzip_root_dirent)) |
|
346 |
+ { WARN1("internal sizeof-mismatch may break wreakage"); } |
|
347 |
+ /* the internal directory structure is never bigger than the |
|
348 |
+ * external zip central directory space had been beforehand |
|
349 |
+ * (as long as the following assertion holds...) |
|
350 |
+ */ |
|
351 |
+ |
|
352 |
+ if (((unsigned)hdr0)&3) |
|
353 |
+ { NOTE1("this machine's malloc(3) returns sth. not u32-aligned"); } |
|
354 |
+ /* we assume that if this machine's malloc has returned a non-aligned |
|
355 |
+ * memory block, then it is actually safe to access misaligned data, and |
|
356 |
+ * since it does only affect the first hdr it should not even bring about |
|
357 |
+ * too much of that cpu's speed penalty |
|
358 |
+ */ |
|
359 |
+# endif |
|
359 | 360 |
|
360 | 361 |
for (entries=u_entries, offset=0; entries > 0; entries--) |
361 | 362 |
{ |
... | ... |
@@ -368,14 +254,55 @@ __zzip_parse_root_directory(int fd, |
368 | 368 |
{ |
369 | 369 |
if (io->seeks(fd, u_rootseek+offset, SEEK_SET) < 0) |
370 | 370 |
return ZZIP_DIR_SEEK; |
371 |
- if (io->read(fd, &dirent, sizeof(dirent)) < __sizeof(dirent)) |
|
371 |
+ if (io->read(fd, &dirent, sizeof(dirent)) < sizeof(dirent)) |
|
372 | 372 |
return ZZIP_DIR_READ; |
373 | 373 |
d = &dirent; |
374 | 374 |
} |
375 | 375 |
|
376 |
- if (offset+sizeof(*d) > u_rootsize) |
|
377 |
- { /*FAIL2("%i's entry stretches beyond root directory", entries);*/ break;} |
|
378 |
- |
|
376 |
+ /* another check for corrupted files */ |
|
377 |
+ if (! ZZIP_ROOT_DIRENT_CHECKMAGIC(d)) |
|
378 |
+ { |
|
379 |
+ cli_errmsg("zziplib: directory entry incorrect: %lx - search %lx...\n", |
|
380 |
+ offset+u_rootseek, fallback_offset+u_rootseek); |
|
381 |
+ offset = fallback_offset; |
|
382 |
+ while (offset < u_rootsize-sizeof(dirent)) |
|
383 |
+ { |
|
384 |
+ offset++; |
|
385 |
+ if (fd_map) |
|
386 |
+ { d = (void*)(fd_map+fd_gap+offset); } |
|
387 |
+ else |
|
388 |
+ { |
|
389 |
+ if (io->seeks(fd, u_rootseek+offset, SEEK_SET) < 0) |
|
390 |
+ return ZZIP_DIR_SEEK; |
|
391 |
+ if (io->read(fd, &dirent, sizeof(dirent.z_magic)) |
|
392 |
+ < sizeof(dirent.z_magic)) |
|
393 |
+ return ZZIP_DIR_READ; |
|
394 |
+ d = &dirent; |
|
395 |
+ } |
|
396 |
+ if (ZZIP_ROOT_DIRENT_CHECKMAGIC(d)) |
|
397 |
+ { |
|
398 |
+ /* HINT2("found directory entry magic at %lx", u_rootseek+offset); */ |
|
399 |
+ break; |
|
400 |
+ } |
|
401 |
+ |
|
402 |
+ } |
|
403 |
+ if (ZZIP_ROOT_DIRENT_CHECKMAGIC(d)) |
|
404 |
+ { |
|
405 |
+ entries++; |
|
406 |
+ continue; |
|
407 |
+ } |
|
408 |
+ |
|
409 |
+ else |
|
410 |
+ { |
|
411 |
+ cli_errmsg("zziplib: directory entry not found\n", |
|
412 |
+ offset+u_rootseek); |
|
413 |
+ return ZZIP_CORRUPTED; |
|
414 |
+ } |
|
415 |
+ } |
|
416 |
+ |
|
417 |
+ |
|
418 |
+ |
|
419 |
+ |
|
379 | 420 |
# if 0 && defined DEBUG |
380 | 421 |
zzip_debug_xbuf ((unsigned char*) d, sizeof(*d) + 8); |
381 | 422 |
# endif |
... | ... |
@@ -383,9 +310,8 @@ __zzip_parse_root_directory(int fd, |
383 | 383 |
u_extras = ZZIP_GET16(d->z_extras); |
384 | 384 |
u_comment = ZZIP_GET16(d->z_comment); |
385 | 385 |
u_namlen = ZZIP_GET16(d->z_namlen); |
386 |
- //HINT5("offset=0x%lx, size %ld, dirent *%p, hdr %p\n", |
|
387 |
- // offset+u_rootseek, (long)u_rootsize, d, hdr); |
|
388 |
- |
|
386 |
+ |
|
387 |
+ |
|
389 | 388 |
/* writes over the read buffer, Since the structure where data is |
390 | 389 |
copied is smaller than the data in buffer this can be done. |
391 | 390 |
It is important that the order of setting the fields is considered |
... | ... |
@@ -400,51 +326,38 @@ __zzip_parse_root_directory(int fd, |
400 | 400 |
hdr->d_compr = (uint8_t)ZZIP_GET16(d->z_compr); |
401 | 401 |
if (hdr->d_compr > 255) hdr->d_compr = 255; |
402 | 402 |
|
403 |
- if (offset+sizeof(*d) + u_namlen > u_rootsize) |
|
404 |
- { /*FAIL2("%i's name stretches beyond root directory", entries);*/ break;} |
|
405 |
- |
|
406 |
- if (fd_map) |
|
407 |
- { memcpy(hdr->d_name, fd_map+fd_gap+offset+sizeof(*d), u_namlen); } |
|
408 |
- else { io->read(fd, hdr->d_name, u_namlen); } |
|
403 |
+ if (fd_map) |
|
404 |
+ { memcpy(hdr->d_name, fd_map+fd_gap+offset+sizeof(*d), u_namlen); } |
|
405 |
+ else |
|
406 |
+ { io->read(fd, hdr->d_name, u_namlen); } |
|
409 | 407 |
hdr->d_name[u_namlen] = '\0'; |
410 | 408 |
hdr->d_namlen = u_namlen; |
411 | 409 |
|
412 | 410 |
/* update offset by the total length of this entry -> next entry */ |
411 |
+ fallback_offset = offset + sizeof(*d) - 1; |
|
413 | 412 |
offset += sizeof(*d) + u_namlen + u_extras + u_comment; |
414 | 413 |
|
415 | 414 |
if (offset > (long)u_rootsize) |
416 |
- { /*FAIL2("%i's end beyond root directory", entries);*/ entries--; break;} |
|
417 |
- |
|
418 |
- //HINT5("file %d { compr=%d crc32=$%x offset=%d", |
|
419 |
- // entries, hdr->d_compr, hdr->d_crc32, hdr->d_off); |
|
420 |
- //HINT5("csize=%d usize=%d namlen=%d extras=%d", |
|
421 |
- // hdr->d_csize, hdr->d_usize, u_namlen, u_extras); |
|
422 |
- //HINT5("comment=%d name='%s' %s <sizeof %d> } ", |
|
423 |
- // u_comment, hdr->d_name, "",(int) sizeof(*d)); |
|
424 |
- |
|
415 |
+ break; |
|
416 |
+ |
|
425 | 417 |
p_reclen = &hdr->d_reclen; |
426 | 418 |
|
427 | 419 |
{ register char* p = (char*) hdr; |
428 | 420 |
register char* q = aligned4 (p + sizeof(*hdr) + u_namlen + 1); |
429 |
- *p_reclen = (uint16_t)(q - p); |
|
421 |
+ *p_reclen = q - p; |
|
430 | 422 |
hdr = (struct zzip_dir_hdr*) q; |
431 | 423 |
} |
432 | 424 |
}/*for*/ |
433 | 425 |
|
434 |
- /*if (USE_MMAP && fd_map) |
|
435 |
- { |
|
436 |
- HINT3("unmap *%p len=%i", fd_map, u_rootsize+fd_gap); |
|
437 |
- _zzip_munmap(io->use_mmap, fd_map, u_rootsize+fd_gap); |
|
438 |
- }*/ |
|
426 |
+ if (!p_reclen) |
|
427 |
+ return 0; /* 0 (sane) entries in zip directory... */ |
|
439 | 428 |
|
440 |
- if (p_reclen) |
|
441 |
- { |
|
442 |
- *p_reclen = 0; /* mark end of list */ |
|
429 |
+ *p_reclen = 0; /* mark end of list */ |
|
443 | 430 |
|
444 |
- if (hdr_return) |
|
445 |
- *hdr_return = hdr0; |
|
446 |
- } /* else zero (sane) entries */ |
|
447 |
- return (entries ? ZZIP_CORRUPTED : 0); |
|
431 |
+ if (hdr_return) |
|
432 |
+ *hdr_return = hdr0; |
|
433 |
+ |
|
434 |
+ return 0; |
|
448 | 435 |
} |
449 | 436 |
|
450 | 437 |
/* ------------------------- high-level interface ------------------------- */ |
... | ... |
@@ -594,18 +507,13 @@ __zzip_dir_parse (ZZIP_DIR* dir) |
594 | 594 |
* { rv = EINVAL; goto error; } |
595 | 595 |
*/ |
596 | 596 |
|
597 |
- //HINT2("------------------ fd=%i", (int) dir->fd); |
|
598 | 597 |
if ((filesize = dir->io->filesize(dir->fd)) < 0) |
599 | 598 |
{ rv = ZZIP_DIR_STAT; goto error; } |
600 | 599 |
|
601 |
- //HINT2("------------------ filesize=%ld", (long) filesize); |
|
602 | 600 |
if ((rv = __zzip_find_disk_trailer(dir->fd, filesize, &trailer, |
603 | 601 |
dir->io)) != 0) |
604 | 602 |
{ goto error; } |
605 | 603 |
|
606 |
- //HINT5("directory = { entries= %d/%d, size= %d, seek= %d } ", |
|
607 |
- // ZZIP_GET16(trailer.z_entries), ZZIP_GET16(trailer.z_finalentries), |
|
608 |
- // ZZIP_GET32(trailer.z_rootsize), ZZIP_GET32(trailer.z_rootseek)); |
|
609 | 604 |
|
610 | 605 |
if ( (rv = __zzip_parse_root_directory(dir->fd, &trailer, &dir->hdr0, |
611 | 606 |
dir->io)) != 0) |
... | ... |
@@ -625,7 +533,7 @@ __zzip_try_open(zzip_char_t* filename, int filemode, |
625 | 625 |
{ |
626 | 626 |
auto char file[PATH_MAX]; |
627 | 627 |
int fd; |
628 |
- zzip_size_t len = strlen (filename); |
|
628 |
+ int len = strlen (filename); |
|
629 | 629 |
|
630 | 630 |
if (len+4 >= PATH_MAX) return -1; |
631 | 631 |
memcpy(file, filename, len+1); |
... | ... |
@@ -75,9 +75,6 @@ ZZIP_DIR* |
75 | 75 |
zzip_dir_fdopen_ext_io(int fd, zzip_error_t * errorcode_p, |
76 | 76 |
zzip_strings_t* ext, const zzip_plugin_io_t io); |
77 | 77 |
|
78 |
-ZZIP_DIR* /*depracated*/ |
|
79 |
-zzip_dir_alloc_ext_io (zzip_strings_t* ext, const zzip_plugin_io_t io); |
|
80 |
- |
|
81 | 78 |
/* get 16/32 bits from little-endian zip-file to host byteorder */ |
82 | 79 |
uint32_t __zzip_get32(unsigned char * s); |
83 | 80 |
uint16_t __zzip_get16(unsigned char * s); |
... | ... |
@@ -3,17 +3,12 @@ |
3 | 3 |
* Guido Draheim <guidod@gmx.de> |
4 | 4 |
* Tomi Ollila <Tomi.Ollila@iki.fi> |
5 | 5 |
* |
6 |
- * Copyright (c) 1999,2000,2001,2002,2003 Guido Draheim |
|
6 |
+ * Copyright (c) 1999,2000,2001,2002 Guido Draheim |
|
7 | 7 |
* All rights reserved, |
8 | 8 |
* usage allowed under the restrictions of the |
9 | 9 |
* Lesser GNU General Public License |
10 | 10 |
* note the additional license information |
11 | 11 |
* that can be found in COPYING.ZZIP |
12 |
- * |
|
13 |
- * if you see "unknown symbol" errors, check first that `-I ..` is part of |
|
14 |
- * your compiler options - a special hint to VC/IDE users who tend to make up |
|
15 |
- * their own workspace files. All includes look like #include <zzip|*.h>, so |
|
16 |
- * you need to add an include path to the dir containing (!!) the ./zzip/ dir |
|
17 | 12 |
*/ |
18 | 13 |
|
19 | 14 |
#ifndef _ZZIP_ZZIP_H /* zziplib.h */ |
... | ... |
@@ -22,8 +17,6 @@ |
22 | 22 |
#include <zzip-conf.h> |
23 | 23 |
|
24 | 24 |
#include <fcntl.h> |
25 |
-#include <stddef.h> /* size_t and friends */ |
|
26 |
-/* msvc6 has neither ssize_t (we assume "int") nor off_t (assume "long") */ |
|
27 | 25 |
|
28 | 26 |
#ifdef __cplusplus |
29 | 27 |
extern "C" { |
... | ... |
@@ -79,8 +72,6 @@ typedef enum |
79 | 79 |
typedef char _zzip_const * _zzip_const zzip_strings_t; |
80 | 80 |
typedef char _zzip_const zzip_char_t; |
81 | 81 |
typedef _zzip_off_t zzip_off_t; |
82 |
-typedef _zzip_size_t zzip_size_t; |
|
83 |
-typedef _zzip_ssize_t zzip_ssize_t; |
|
84 | 82 |
typedef struct zzip_dir ZZIP_DIR; |
85 | 83 |
typedef struct zzip_file ZZIP_FILE; |
86 | 84 |
typedef struct zzip_dirent ZZIP_DIRENT; |
... | ... |
@@ -96,7 +87,7 @@ struct zzip_dirent |
96 | 96 |
|
97 | 97 |
/* |
98 | 98 |
* Getting error strings |
99 |
- * zzip/err.c |
|
99 |
+ * zzip-err.c |
|
100 | 100 |
*/ |
101 | 101 |
_zzip_export /* error in _opendir : */ |
102 | 102 |
zzip_char_t* zzip_strerror(int errcode); |
... | ... |
@@ -109,7 +100,7 @@ int zzip_errno(int errcode); |
109 | 109 |
/* |
110 | 110 |
* Functions to grab information from ZZIP_DIR/ZZIP_FILE structure |
111 | 111 |
* (if ever needed) |
112 |
- * zzip/info.c |
|
112 |
+ * zzip-info.c |
|
113 | 113 |
*/ |
114 | 114 |
_zzip_export |
115 | 115 |
int zzip_error(ZZIP_DIR * dir); |
... | ... |
@@ -133,7 +124,7 @@ int zzip_realfd(ZZIP_FILE * fp); |
133 | 133 |
|
134 | 134 |
/* |
135 | 135 |
* zip handle management |
136 |
- * zzip/zip.c |
|
136 |
+ * zzip-zip.c |
|
137 | 137 |
*/ |
138 | 138 |
_zzip_export |
139 | 139 |
ZZIP_DIR * zzip_dir_alloc(zzip_strings_t* fileext); |
... | ... |
@@ -156,8 +147,8 @@ int zzip_dir_read(ZZIP_DIR * dir, ZZIP_DIRENT * dirent); |
156 | 156 |
|
157 | 157 |
/* |
158 | 158 |
* Scanning files in zip archive |
159 |
- * zzip/dir.c |
|
160 |
- * zzip/zip.c |
|
159 |
+ * zzip-dir.c |
|
160 |
+ * zzip-zip.c |
|
161 | 161 |
*/ |
162 | 162 |
_zzip_export |
163 | 163 |
ZZIP_DIR * zzip_opendir(zzip_char_t* filename); |
... | ... |
@@ -174,33 +165,30 @@ void zzip_seekdir(ZZIP_DIR * dir, zzip_off_t offset); |
174 | 174 |
|
175 | 175 |
/* |
176 | 176 |
* 'opening', 'closing' and reading invidual files in zip archive. |
177 |
- * zzip/file.c |
|
177 |
+ * zzip-file.c |
|
178 | 178 |
*/ |
179 |
+ |
|
179 | 180 |
_zzip_export |
180 | 181 |
ZZIP_FILE * zzip_file_open(ZZIP_DIR * dir, zzip_char_t* name, int modes); |
181 | 182 |
_zzip_export |
182 | 183 |
int zzip_file_close(ZZIP_FILE * fp); |
183 | 184 |
_zzip_export |
184 |
-zzip_ssize_t zzip_file_read(ZZIP_FILE * fp, char* buf, zzip_size_t len); |
|
185 |
+int zzip_file_read(ZZIP_FILE * fp, char* buf, int len); |
|
185 | 186 |
|
186 | 187 |
_zzip_export |
187 | 188 |
ZZIP_FILE * zzip_open(zzip_char_t* name, int flags); |
188 | 189 |
_zzip_export |
189 | 190 |
int zzip_close(ZZIP_FILE * fp); |
190 | 191 |
_zzip_export |
191 |
-zzip_ssize_t zzip_read(ZZIP_FILE * fp, char * buf, zzip_size_t len); |
|
192 |
+int zzip_read(ZZIP_FILE * fp, char * buf, int len); |
|
193 |
+ |
|
192 | 194 |
|
193 |
-/* |
|
194 |
- * the stdc variant to open/read/close files. - Take note of the freopen() |
|
195 |
- * call as it may reuse an existing preparsed copy of a zip central directory |
|
196 |
- */ |
|
197 | 195 |
_zzip_export |
198 | 196 |
ZZIP_FILE* zzip_freopen(zzip_char_t* name, zzip_char_t* mode, ZZIP_FILE*); |
199 | 197 |
_zzip_export |
200 | 198 |
ZZIP_FILE* zzip_fopen(zzip_char_t* name, zzip_char_t* mode); |
201 | 199 |
_zzip_export |
202 |
-zzip_size_t zzip_fread(void *ptr, zzip_size_t size, zzip_size_t nmemb, |
|
203 |
- ZZIP_FILE * file); |
|
200 |
+int zzip_fread(void *ptr, int size, int nmemb, ZZIP_FILE *file); |
|
204 | 201 |
_zzip_export |
205 | 202 |
int zzip_fclose(ZZIP_FILE * fp); |
206 | 203 |
|
... | ... |
@@ -210,18 +198,21 @@ int zzip_fclose(ZZIP_FILE * fp); |
210 | 210 |
_zzip_export |
211 | 211 |
int zzip_rewind(ZZIP_FILE *fp); |
212 | 212 |
_zzip_export |
213 |
-zzip_off_t zzip_seek(ZZIP_FILE * fp, zzip_off_t offset, int whence); |
|
213 |
+int zzip_seek(ZZIP_FILE * fp, int offset, int |
|
214 |
+ whence); |
|
214 | 215 |
_zzip_export |
215 |
-zzip_off_t zzip_tell(ZZIP_FILE * fp); |
|
216 |
+int zzip_tell(ZZIP_FILE * fp); |
|
217 |
+ |
|
216 | 218 |
|
217 | 219 |
/* |
218 | 220 |
* reading info of a single file |
219 |
- * zzip/stat.c |
|
221 |
+ * zzip-stat.c |
|
220 | 222 |
*/ |
221 | 223 |
_zzip_export |
222 | 224 |
int zzip_dir_stat(ZZIP_DIR * dir, zzip_char_t* name, |
223 | 225 |
ZZIP_STAT * zs, int flags); |
224 | 226 |
|
227 |
+ |
|
225 | 228 |
#ifdef ZZIP_LARGEFILE_RENAME |
226 | 229 |
#define zzip_open_shared_io zzip_open_shared_io64 |
227 | 230 |
#define zzip_open_ext_io zzip_open_ext_io64 |
... | ... |
@@ -255,73 +246,13 @@ ZZIP_FILE * zzip_file_open_ext_io(ZZIP_DIR * dir, |
255 | 255 |
zzip_strings_t* ext, zzip_plugin_io_t io); |
256 | 256 |
|
257 | 257 |
_zzip_export |
258 |
-ZZIP_DIR * zzip_dir_open_ext_io(zzip_char_t* filename, |
|
258 |
+ZZIP_DIR * zzip_dir_open_ext_io(zzip_char_t* filename, |
|
259 | 259 |
zzip_error_t* errcode_p, |
260 | 260 |
zzip_strings_t* ext, zzip_plugin_io_t io); |
261 | 261 |
|
262 |
-#if defined _ZZIP_WRITE_SOURCE |
|
263 |
-/* ........................................................................ |
|
264 |
- * write support is not yet implemented |
|
265 |
- * zzip/write.c |
|
266 |
- */ |
|
267 |
-#define ZZIP_NO_CREAT 1 |
|
268 |
- |
|
269 |
-ZZIP_DIR* zzip_dir_creat_ext_io(zzip_char_t* name, int o_mode, |
|
270 |
- zzip_strings_t* ext, zzip_plugin_io_t io); |
|
271 |
-ZZIP_DIR* zzip_dir_creat(zzip_char_t* name, int o_mode); |
|
272 |
-int zzip_file_mkdir(ZZIP_DIR* dir, zzip_char_t* name, int o_mode); |
|
273 |
-ZZIP_FILE* zzip_file_creat(ZZIP_DIR* dir, zzip_char_t* name, int o_mode); |
|
274 |
-zzip_ssize_t zzip_file_write(ZZIP_FILE* file, |
|
275 |
- const void* ptr, zzip_size_t len); |
|
276 |
- |
|
277 |
-ZZIP_DIR* zzip_createdir(zzip_char_t* name, int o_mode); |
|
278 |
-zzip_ssize_t zzip_write(ZZIP_FILE* file, const void* ptr, zzip_size_t len); |
|
279 |
-zzip_size_t zzip_fwrite(const void* ptr, zzip_size_t len, |
|
280 |
- zzip_size_t multiply, ZZIP_FILE* file); |
|
281 |
-#ifndef zzip_savefile |
|
282 |
-#define zzip_savefile 0 |
|
283 |
-#define zzip_savefile_is_null |
|
284 |
-#endif |
|
285 |
- |
|
286 |
-#ifdef _ZZIP_NO_INLINE |
|
287 |
-#define zzip_mkdir(_name_,_mode_) \ |
|
288 |
- zzip_file_mkdir((zzip_savefile),(_name_),(_mode_)) |
|
289 |
-#define zzip_creat(_name_,_mode_) \ |
|
290 |
- zzip_file_creat((zzip_savefile),(_name_),(_mode_)) |
|
291 |
-#define zzip_sync() \ |
|
292 |
- { zzip_closedir((zzip_savefile)); (zzip_savefile) = 0; } |
|
293 |
-#define zzip_start(_name_,_mode_,_ext_) \ |
|
294 |
- { if ((zzip_savefile)) zzip_closedir((zzip_savefile)); |
|
295 |
- zzip_savefile = zzip_dir_creat(_name_, _mode_,_ext_); } |
|
296 |
- |
|
297 |
-#else |
|
298 |
- |
|
299 |
-_zzip_inline static int zzip_mkdir(zzip_char_t* name, int o_mode) |
|
300 |
-{ return zzip_file_mkdir(zzip_savefile, name, o_mode); } |
|
301 |
-_zzip_inline static ZZIP_FILE* zzip_creat(zzip_char_t* name, int o_mode) |
|
302 |
-{ return zzip_file_creat(zzip_savefile, name, o_mode); } |
|
303 |
- |
|
304 |
-#ifndef zzip_savefile_is_null |
|
305 |
-_zzip_inline static void zzip_sync(void) |
|
306 |
-{ zzip_closedir(zzip_savefile); zzip_savefile = 0; } |
|
307 |
-_zzip_inline static void zzip_mkfifo(zzip_char_t* name, int o_mode) |
|
308 |
-{ if ((zzip_savefile)) zzip_closedir (zzip_savefile); |
|
309 |
- zzip_savefile = zzip_createdir(_name_,_mode_); } |
|
310 |
-#else |
|
311 |
-_zzip_inline static void zzip_sync(void) {} |
|
312 |
-_zzip_inline static void zzip_mkfifo(zzip_char_t* name, int o_mode) {} |
|
313 |
-#endif |
|
314 |
-#endif /* _ZZIP_NO_INLINE */ |
|
315 |
-#endif /* _ZZIP_WRITE_SOURCE */ |
|
316 |
- |
|
317 | 262 |
#ifdef __cplusplus |
318 | 263 |
}; |
319 | 264 |
#endif |
320 | 265 |
|
321 | 266 |
#endif /* _ZZIPLIB_H */ |
322 | 267 |
|
323 |
-/* |
|
324 |
- * Local variables: |
|
325 |
- * c-file-style: "stroustrup" |
|
326 |
- * End: |
|
327 |
- */ |
... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
/* |
2 |
- * Copyright (C) 2001-2002 Tomasz Kojm <zolw@konarski.edu.pl> |
|
2 |
+ * Copyright (C) 2001-2003 Tomasz Kojm <zolw@konarski.edu.pl> |
|
3 | 3 |
* |
4 | 4 |
* This program is free software; you can redistribute it and/or modify |
5 | 5 |
* it under the terms of the GNU General Public License as published by |
... | ... |
@@ -23,6 +23,10 @@ |
23 | 23 |
#define _GNU_SOURCE |
24 | 24 |
#include "getopt.h" |
25 | 25 |
|
26 |
+#if defined(C_LINUX) && defined(CL_DEBUG) |
|
27 |
+#include <sys/resource.h> |
|
28 |
+#endif |
|
29 |
+ |
|
26 | 30 |
#include "options.h" |
27 | 31 |
#include "others.h" |
28 | 32 |
#include "shared.h" |
... | ... |
@@ -53,6 +57,14 @@ int main(int argc, char **argv) |
53 | 53 |
{0, 0, 0, 0} |
54 | 54 |
}; |
55 | 55 |
|
56 |
+#if defined(C_LINUX) && defined(CL_DEBUG) |
|
57 |
+ /* njh@bandsman.co.uk: create a dump if needed */ |
|
58 |
+ struct rlimit rlim; |
|
59 |
+ |
|
60 |
+ rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY; |
|
61 |
+ if(setrlimit(RLIMIT_CORE, &rlim) < 0) |
|
62 |
+ perror("setrlimit"); |
|
63 |
+#endif |
|
56 | 64 |
|
57 | 65 |
opt=(struct optstruct*)mmalloc(sizeof(struct optstruct)); |
58 | 66 |
opt->optlist = NULL; |
... | ... |
@@ -1,5 +1,3 @@ |
1 |
-/* THIS CODE SUCKS */ |
|
2 |
- |
|
3 | 1 |
/* |
4 | 2 |
* Copyright (C) 2002, 2003 Tomasz Kojm <zolw@konarski.edu.pl> |
5 | 3 |
* |
... | ... |
@@ -35,6 +33,10 @@ |
35 | 35 |
#include "strings.h" |
36 | 36 |
|
37 | 37 |
#define LINE 1024 |
38 |
+ |
|
39 |
+#define MIN_LENGTH 15 |
|
40 |
+#define MAX_LENGTH 200 |
|
41 |
+ |
|
38 | 42 |
void help(void); |
39 | 43 |
|
40 | 44 |
int scanfile(const char *cmd, const char *str, const char *file) |
... | ... |
@@ -66,7 +68,7 @@ int scanfile(const char *cmd, const char *str, const char *file) |
66 | 66 |
|
67 | 67 |
char *cut(const char *file, long int start, long int end) |
68 | 68 |
{ |
69 |
- char *fname, buffer[FBUFFSIZE]; |
|
69 |
+ char *fname = NULL, buffer[FBUFFSIZE]; |
|
70 | 70 |
int bytes, size, sum; |
71 | 71 |
FILE *rd, *wd; |
72 | 72 |
|
... | ... |
@@ -76,7 +78,11 @@ char *cut(const char *file, long int start, long int end) |
76 | 76 |
exit(13); |
77 | 77 |
} |
78 | 78 |
|
79 |
- fname = cl_gentemp("."); |
|
79 |
+ if((fname = cl_gentemp(".")) == NULL) { |
|
80 |
+ mprintf("!Can't generate temporary file name.\n"); |
|
81 |
+ exit(1); |
|
82 |
+ } |
|
83 |
+ |
|
80 | 84 |
if((wd = fopen(fname, "wb")) == NULL) { |
81 | 85 |
mprintf("!Can't create temporary file %s\n", fname); |
82 | 86 |
exit(14); |
... | ... |
@@ -90,7 +96,6 @@ char *cut(const char *file, long int start, long int end) |
90 | 90 |
while((bytes = fread(buffer, 1, FBUFFSIZE, rd)) > 0) { |
91 | 91 |
if(sum + bytes >= size) { |
92 | 92 |
fwrite(buffer, 1, size - sum, wd); |
93 |
- //fwrite(buffer, 1, size - bytes, wd); |
|
94 | 93 |
break; |
95 | 94 |
} else |
96 | 95 |
fwrite(buffer, 1, bytes, wd); |
... | ... |
@@ -100,12 +105,13 @@ char *cut(const char *file, long int start, long int end) |
100 | 100 |
|
101 | 101 |
fclose(rd); |
102 | 102 |
fclose(wd); |
103 |
+ |
|
103 | 104 |
return fname; |
104 | 105 |
} |
105 | 106 |
|
106 | 107 |
char *change(const char *file, long int x) |
107 | 108 |
{ |
108 |
- char *fname, buffer[FBUFFSIZE]; |
|
109 |
+ char *fname = NULL, buffer[FBUFFSIZE]; |
|
109 | 110 |
int bytes, size, sum, ch; |
110 | 111 |
FILE *rd, *wd; |
111 | 112 |
|
... | ... |
@@ -115,7 +121,11 @@ char *change(const char *file, long int x) |
115 | 115 |
exit(13); |
116 | 116 |
} |
117 | 117 |
|
118 |
- fname = cl_gentemp("."); |
|
118 |
+ if((fname = cl_gentemp(".")) == NULL) { |
|
119 |
+ mprintf("!Can't generate temporary file name.\n"); |
|
120 |
+ exit(1); |
|
121 |
+ } |
|
122 |
+ |
|
119 | 123 |
if((wd = fopen(fname, "wb+")) == NULL) { |
120 | 124 |
mprintf("!Can't create temporary file %s\n", fname); |
121 | 125 |
exit(14); |
... | ... |
@@ -126,11 +136,14 @@ char *change(const char *file, long int x) |
126 | 126 |
|
127 | 127 |
fclose(rd); |
128 | 128 |
|
129 |
- fflush(wd); |
|
130 |
- fseek(wd, x, SEEK_SET); |
|
131 |
- ch = fgetc(wd); |
|
132 |
- fseek(wd, -1, SEEK_CUR); |
|
133 |
- fputc(++ch, wd); |
|
129 |
+ if(x) { /* don't alter first character in the file */ |
|
130 |
+ fflush(wd); |
|
131 |
+ fseek(wd, x, SEEK_SET); |
|
132 |
+ ch = fgetc(wd); |
|
133 |
+ fseek(wd, -1, SEEK_CUR); |
|
134 |
+ fputc(++ch, wd); |
|
135 |
+ } |
|
136 |
+ |
|
134 | 137 |
fclose(wd); |
135 | 138 |
return fname; |
136 | 139 |
} |
... | ... |
@@ -161,7 +174,6 @@ void sigtool(struct optstruct *opt) |
161 | 161 |
help(); |
162 | 162 |
} |
163 | 163 |
|
164 |
- |
|
165 | 164 |
if(optl(opt, "hex-dump")) { |
166 | 165 |
|
167 | 166 |
while((bytes = read(0, buffer, FBUFFSIZE)) > 0) { |
... | ... |
@@ -179,7 +191,8 @@ void sigtool(struct optstruct *opt) |
179 | 179 |
cvdinfo(opt); |
180 | 180 |
|
181 | 181 |
} else { |
182 |
- int jmp, lastjmp, start, end, found = 0, exec = 0, pos, filesize; |
|
182 |
+ int jmp, lastjmp, start, end, found = 0, exec = 0, pos, filesize, |
|
183 |
+ maxsize = 0, ret; |
|
183 | 184 |
char *c, *s, *f, *tmp, *signame, *bsigname, *f2; |
184 | 185 |
FILE *fd, *wd; |
185 | 186 |
|
... | ... |
@@ -210,35 +223,33 @@ void sigtool(struct optstruct *opt) |
210 | 210 |
filesize = end = fileinfo(f, 1); |
211 | 211 |
jmp = end / 5 + 1; |
212 | 212 |
|
213 |
- /* find signature's END */ |
|
213 |
+ /* find signature end */ |
|
214 | 214 |
while(1) { |
215 | 215 |
tmp = cut(f, 0, end); |
216 | 216 |
exec++; |
217 |
- if(scanfile(c, s, tmp) == 1) { |
|
218 |
- if(!end) { |
|
219 |
- mprintf("end == 0, stopping loop\n"); |
|
220 |
- unlink(tmp); |
|
221 |
- free(tmp); |
|
222 |
- break; |
|
223 |
- } |
|
224 |
- mprintf("Detected, decreasing end %d -> %d\n", end, end - jmp); |
|
225 |
- end -= jmp; |
|
226 |
- unlink(tmp); |
|
227 |
- free(tmp); |
|
217 |
+ ret = scanfile(c, s, tmp); |
|
218 |
+ unlink(tmp); |
|
219 |
+ free(tmp); |
|
220 |
+ |
|
221 |
+ if(ret == 1) { |
|
222 |
+ |
|
223 |
+ if(end >= jmp) { |
|
224 |
+ mprintf("Detected, decreasing end %d -> %d\n", end, end - jmp); |
|
225 |
+ end -= jmp; |
|
226 |
+ } else |
|
227 |
+ end = 0; |
|
228 |
+ |
|
228 | 229 |
} else { |
229 | 230 |
mprintf("Not detected at %d, moving forward.\n", end); |
230 | 231 |
if(jmp == 1) { |
231 |
- unlink(tmp); |
|
232 |
- free(tmp); |
|
233 |
- //mprintf("Starting precise loop\n"); |
|
232 |
+ |
|
234 | 233 |
while(end <= filesize) { |
235 | 234 |
tmp = cut(f, 0, end); |
236 | 235 |
exec++; |
237 | 236 |
if(scanfile(c, s, tmp) == 1) { |
238 |
- mprintf(" *** Found signature's end at %d\n", end); |
|
237 |
+ mprintf(" *** Signature end found at %d\n", end); |
|
239 | 238 |
found = 1; |
240 |
- // unlink(tmp); |
|
241 |
- f2 = strdup(tmp); |
|
239 |
+ f2 = strdup(tmp); /* remember this file */ |
|
242 | 240 |
free(tmp); |
243 | 241 |
break; |
244 | 242 |
} else { |
... | ... |
@@ -251,6 +262,7 @@ void sigtool(struct optstruct *opt) |
251 | 251 |
|
252 | 252 |
if(found) break; |
253 | 253 |
} |
254 |
+ |
|
254 | 255 |
if(jmp) |
255 | 256 |
jmp--; |
256 | 257 |
jmp = jmp/2 + 1; |
... | ... |
@@ -264,56 +276,83 @@ void sigtool(struct optstruct *opt) |
264 | 264 |
|
265 | 265 |
} |
266 | 266 |
|
267 |
- /* now we go backward until the signature can't be detected */ |
|
268 |
- |
|
267 |
+ /* find signature beginning */ |
|
269 | 268 |
found = 0; |
270 | 269 |
jmp = 50; |
271 | 270 |
pos = end - jmp; |
272 | 271 |
|
273 | 272 |
while(1) { |
274 |
- if(pos < 0) //!!!!!!???? |
|
275 |
- pos = 0; |
|
276 | 273 |
|
277 | 274 |
tmp = change(f2, pos); |
278 |
- exec++; |
|
279 | 275 |
if(scanfile(c, s, tmp) != 1) { |
280 |
- mprintf("Not detected, moving backward %d -> %d\n", pos, pos - jmp); |
|
281 |
- pos -= jmp; |
|
276 |
+ exec++; |
|
282 | 277 |
unlink(tmp); |
283 | 278 |
free(tmp); |
284 | 279 |
|
280 |
+ if(pos >= jmp) { |
|
281 |
+ mprintf("Not detected, moving backward %d -> %d\n", pos, pos - jmp); |
|
282 |
+ pos -= jmp; |
|
283 |
+ maxsize += jmp; |
|
284 |
+ } else { |
|
285 |
+ mprintf("Not detected, using the beginning of the file.\n"); |
|
286 |
+ pos = 0; |
|
287 |
+ break; |
|
288 |
+ } |
|
289 |
+ |
|
290 |
+ if(maxsize > MAX_LENGTH) { |
|
291 |
+ mprintf("!Generated signature is too big.\n"); |
|
292 |
+ unlink(f2); |
|
293 |
+ free(f2); |
|
294 |
+ exit(1); |
|
295 |
+ } |
|
296 |
+ |
|
285 | 297 |
} else { |
286 | 298 |
mprintf("Detected at %d, moving forward.\n", pos); |
287 | 299 |
if(jmp == 1 && lastjmp == 1) { |
288 | 300 |
unlink(tmp); |
289 | 301 |
free(tmp); |
290 |
- //mprintf("Starting precise loop\n"); |
|
291 | 302 |
while(pos < end) { |
292 | 303 |
tmp = change(f2, pos); |
293 | 304 |
exec++; |
294 |
- if(scanfile(c, s, tmp) == 1) { |
|
295 |
- unlink(tmp); |
|
296 |
- free(tmp); |
|
305 |
+ ret = scanfile(c, s, tmp); |
|
306 |
+ unlink(tmp); |
|
307 |
+ free(tmp); |
|
308 |
+ if(ret == 1) { |
|
297 | 309 |
mprintf("Moving forward %d -> %d\n", pos, pos + 1); |
298 | 310 |
pos++; |
311 |
+ |
|
312 |
+ if(end - pos < MIN_LENGTH) { |
|
313 |
+ mprintf("!Generated signature is too small.\n"); |
|
314 |
+ unlink(f2); |
|
315 |
+ free(f2); |
|
316 |
+ exit(1); |
|
317 |
+ } |
|
318 |
+ |
|
299 | 319 |
} else { |
300 | 320 |
mprintf(" *** Found signature's start at %d\n", pos); |
301 |
- unlink(tmp); |
|
302 |
- free(tmp); |
|
303 | 321 |
found = 1; |
304 | 322 |
break; |
305 | 323 |
} |
306 | 324 |
} |
307 |
- if(found) break; |
|
325 |
+ |
|
326 |
+ if(pos >= end) { |
|
327 |
+ mprintf("!Can't generate a proper signature.\n"); |
|
328 |
+ unlink(f2); |
|
329 |
+ free(f2); |
|
330 |
+ exit(1); |
|
331 |
+ } |
|
332 |
+ |
|
333 |
+ if(found) |
|
334 |
+ break; |
|
308 | 335 |
} |
309 | 336 |
|
310 | 337 |
lastjmp = jmp; |
311 |
- if(jmp) |
|
338 |
+ if(jmp > 0) |
|
312 | 339 |
jmp--; |
313 |
- jmp = jmp/2 + 1; //?????????????? |
|
340 |
+ jmp = jmp/2 + 1; |
|
314 | 341 |
pos += jmp; |
315 | 342 |
|
316 |
- if(pos > end) |
|
343 |
+ if(pos >= end - 2 * jmp) |
|
317 | 344 |
pos = end - 2 * jmp; |
318 | 345 |
|
319 | 346 |
unlink(tmp); |
... | ... |
@@ -329,8 +368,8 @@ void sigtool(struct optstruct *opt) |
329 | 329 |
mprintf("\nThe scanner was executed %d times.\n", exec); |
330 | 330 |
mprintf("The signature length is %d, so the length of the hex string should be %d\n", end - pos, 2 * (end - pos)); |
331 | 331 |
|
332 |
- if(end - pos < 8) { |
|
333 |
- mprintf("\nWARNING: THE SIGNATURE IS TO SMALL (PROBABLY ONLY A PART OF A REAL SIGNATURE).\n"); |
|
332 |
+ if(end - pos < MIN_LENGTH) { |
|
333 |
+ mprintf("\nWARNING: THE SIGNATURE IS TOO SMALL (PROBABLY ONLY A PART OF A REAL SIGNATURE).\n"); |
|
334 | 334 |
mprintf(" PLEASE DON'T USE IT.\n\n"); |
335 | 335 |
} |
336 | 336 |
|
... | ... |
@@ -380,7 +419,7 @@ void sigtool(struct optstruct *opt) |
380 | 380 |
free(bsigname); |
381 | 381 |
} |
382 | 382 |
|
383 |
- //free_opt(opt); |
|
383 |
+ /* free_opt(opt); */ |
|
384 | 384 |
} |
385 | 385 |
|
386 | 386 |
int build(struct optstruct *opt) |
... | ... |
@@ -396,7 +435,7 @@ int build(struct optstruct *opt) |
396 | 396 |
struct tm *brokent; |
397 | 397 |
|
398 | 398 |
/* build a tar.gz archive |
399 |
- * we need: COPYING, viruses.db / viruses.db2 |
|
399 |
+ * we need: COPYING and {viruses.db, viruses.db2}+ |
|
400 | 400 |
* in current working directory |
401 | 401 |
*/ |
402 | 402 |
|
... | ... |
@@ -485,8 +524,7 @@ int build(struct optstruct *opt) |
485 | 485 |
|
486 | 486 |
/* version number */ |
487 | 487 |
|
488 |
- // tutaj ma przeczytac naglowek z obecnej bazy o tej samej nazwie |
|
489 |
- // i uzyc o jeden wiekszy |
|
488 |
+ /* ... increment version number by one */ |
|
490 | 489 |
|
491 | 490 |
mprintf("!Can't read database version number from current local database\n"); |
492 | 491 |
fflush(stdin); |
... | ... |
@@ -499,8 +537,7 @@ int build(struct optstruct *opt) |
499 | 499 |
sprintf(smbuff, "%d:", no); |
500 | 500 |
strcat(header, smbuff); |
501 | 501 |
|
502 |
- /* functionality level */ |
|
503 |
- // pobierac z cl_funclevel() |
|
502 |
+ /* functionality level (TODO: use cl_funclevel()) */ |
|
504 | 503 |
sprintf(smbuff, "%d:", 1); |
505 | 504 |
strcat(header, smbuff); |
506 | 505 |
|
... | ... |
@@ -515,10 +552,8 @@ int build(struct optstruct *opt) |
515 | 515 |
/* builder */ |
516 | 516 |
fflush(stdin); |
517 | 517 |
mprintf("Builder name: "); |
518 |
- //fgets(smbuff, 24, stdin); |
|
519 | 518 |
fscanf(stdin, "%s:", &smbuff); |
520 | 519 |
strcat(header, smbuff); |
521 |
- //strcat(header, ":"); |
|
522 | 520 |
|
523 | 521 |
/* fill up with spaces */ |
524 | 522 |
if(strlen(header) > 512) { |
... | ... |
@@ -555,7 +590,7 @@ int build(struct optstruct *opt) |
555 | 555 |
|
556 | 556 |
mprintf("Database %s created.\n", pt); |
557 | 557 |
|
558 |
- // teraz zaladuj baze |
|
558 |
+ /* try to load final cvd */ |
|
559 | 559 |
} |
560 | 560 |
|
561 | 561 |
void cvdinfo(struct optstruct *opt) |
... | ... |
@@ -588,7 +623,7 @@ void cvdinfo(struct optstruct *opt) |
588 | 588 |
else |
589 | 589 |
mprintf("Verification OK.\n"); |
590 | 590 |
|
591 |
- // wyczysc cvd |
|
591 |
+ /* free */ |
|
592 | 592 |
} |
593 | 593 |
|
594 | 594 |
void help(void) |