git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@476 77e5149b-7576-45b1-b177-96237e5ba77b
Tomasz Kojm authored on 2004/04/06 21:14:53... | ... |
@@ -76,6 +76,7 @@ James F. Hranicky <jfh*cise.ufl.edu> |
76 | 76 |
Andy Igoshin <ai*vsu.ru> |
77 | 77 |
Jesper Juhl <juhl*dif.dk> |
78 | 78 |
Nicholas M. Kirsch <nick*kirsch.org> |
79 |
+Bastian Kleineidam <calvin*debian.org> |
|
79 | 80 |
Robbert Kouprie <robbert*exx.nl> |
80 | 81 |
Martin Kraft <martin.kraft*fal.de> |
81 | 82 |
Thomas Lamy <Thomas.Lamy*in-online.net> |
... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Tue Apr 6 14:19:16 CEST 2004 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * global hardening patch: use strlcpy/strlcat instead of strncpy/strncat |
|
4 |
+ (Bastian Kleineidam <calvin*debian.org>) |
|
5 |
+ |
|
1 | 6 |
Mon Apr 5 23:49:23 CEST 2004 (tk) |
2 | 7 |
---------------------------------- |
3 | 8 |
* contrib: new init script for SuSE (by Martin Fuxa <yeti*email.cz>) |
... | ... |
@@ -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.31 2004/04/05 21:42:10 kojm Exp $ |
|
84 |
+dnl @version: $Id: aclocal.m4,v 1.32 2004/04/06 12:14:52 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.31 2004/04/05 21:42:10 kojm Exp $ |
|
4044 |
+dnl @version $Id: aclocal.m4,v 1.32 2004/04/06 12:14:52 kojm Exp $ |
|
4045 | 4045 |
dnl |
4046 | 4046 |
AC_DEFUN([AC_COMPILE_CHECK_SIZEOF], |
4047 | 4047 |
[changequote(<<, >>)dnl |
... | ... |
@@ -129,6 +129,12 @@ |
129 | 129 |
/* Define to 1 if you have the <string.h> header file. */ |
130 | 130 |
#undef HAVE_STRING_H |
131 | 131 |
|
132 |
+/* Define to 1 if you have the `strlcat' function. */ |
|
133 |
+#undef HAVE_STRLCAT |
|
134 |
+ |
|
135 |
+/* Define to 1 if you have the `strlcpy' function. */ |
|
136 |
+#undef HAVE_STRLCPY |
|
137 |
+ |
|
132 | 138 |
/* Define to 1 if you have the <sys/inttypes.h> header file. */ |
133 | 139 |
#undef HAVE_SYS_INTTYPES_H |
134 | 140 |
|
... | ... |
@@ -28,6 +28,8 @@ clamav_milter_SOURCES = \ |
28 | 28 |
$(top_srcdir)/shared/getopt.h \ |
29 | 29 |
$(top_srcdir)/shared/memory.c \ |
30 | 30 |
$(top_srcdir)/shared/memory.h \ |
31 |
+ $(top_srcdir)/shared/strutil.c \ |
|
32 |
+ $(top_srcdir)/shared/strutil.h \ |
|
31 | 33 |
clamav-milter.c |
32 | 34 |
|
33 | 35 |
man_MANS = $(top_srcdir)/docs/man/clamav-milter.8 |
... | ... |
@@ -127,6 +127,8 @@ install_sh = @install_sh@ |
127 | 127 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ $(top_srcdir)/shared/getopt.h \ |
128 | 128 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ $(top_srcdir)/shared/memory.c \ |
129 | 129 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ $(top_srcdir)/shared/memory.h \ |
130 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ $(top_srcdir)/shared/strutil.c \ |
|
131 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ $(top_srcdir)/shared/strutil.h \ |
|
130 | 132 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ clamav-milter.c |
131 | 133 |
|
132 | 134 |
|
... | ... |
@@ -152,6 +154,7 @@ PROGRAMS = $(sbin_PROGRAMS) |
152 | 152 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ cfgparser.$(OBJEXT) \ |
153 | 153 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ getopt.$(OBJEXT) \ |
154 | 154 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ memory.$(OBJEXT) \ |
155 |
+@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ strutil.$(OBJEXT) \ |
|
155 | 156 |
@BUILD_CLAMD_TRUE@@HAVE_MILTER_TRUE@ clamav-milter.$(OBJEXT) |
156 | 157 |
clamav_milter_OBJECTS = $(am_clamav_milter_OBJECTS) |
157 | 158 |
clamav_milter_LDADD = $(LDADD) |
... | ... |
@@ -164,7 +167,7 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp |
164 | 164 |
am__depfiles_maybe = depfiles |
165 | 165 |
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/cfgparser.Po \ |
166 | 166 |
@AMDEP_TRUE@ ./$(DEPDIR)/clamav-milter.Po ./$(DEPDIR)/getopt.Po \ |
167 |
-@AMDEP_TRUE@ ./$(DEPDIR)/memory.Po |
|
167 |
+@AMDEP_TRUE@ ./$(DEPDIR)/memory.Po ./$(DEPDIR)/strutil.Po |
|
168 | 168 |
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
169 | 169 |
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
170 | 170 |
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ |
... | ... |
@@ -219,6 +222,7 @@ clean-sbinPROGRAMS: |
219 | 219 |
cfgparser.$(OBJEXT): $(top_srcdir)/shared/cfgparser.c |
220 | 220 |
getopt.$(OBJEXT): $(top_srcdir)/shared/getopt.c |
221 | 221 |
memory.$(OBJEXT): $(top_srcdir)/shared/memory.c |
222 |
+strutil.$(OBJEXT): $(top_srcdir)/shared/strutil.c |
|
222 | 223 |
clamav-milter$(EXEEXT): $(clamav_milter_OBJECTS) $(clamav_milter_DEPENDENCIES) |
223 | 224 |
@rm -f clamav-milter$(EXEEXT) |
224 | 225 |
$(LINK) $(clamav_milter_LDFLAGS) $(clamav_milter_OBJECTS) $(clamav_milter_LDADD) $(LIBS) |
... | ... |
@@ -233,6 +237,7 @@ distclean-compile: |
233 | 233 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clamav-milter.Po@am__quote@ |
234 | 234 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ |
235 | 235 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memory.Po@am__quote@ |
236 |
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strutil.Po@am__quote@ |
|
236 | 237 |
|
237 | 238 |
distclean-depend: |
238 | 239 |
-rm -rf ./$(DEPDIR) |
... | ... |
@@ -308,6 +313,24 @@ memory.lo: $(top_srcdir)/shared/memory.c |
308 | 308 |
@AMDEP_TRUE@ depfile='$(DEPDIR)/memory.Plo' tmpdepfile='$(DEPDIR)/memory.TPlo' @AMDEPBACKSLASH@ |
309 | 309 |
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
310 | 310 |
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o memory.lo `test -f '$(top_srcdir)/shared/memory.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/memory.c |
311 |
+ |
|
312 |
+strutil.o: $(top_srcdir)/shared/strutil.c |
|
313 |
+@AMDEP_TRUE@ source='$(top_srcdir)/shared/strutil.c' object='strutil.o' libtool=no @AMDEPBACKSLASH@ |
|
314 |
+@AMDEP_TRUE@ depfile='$(DEPDIR)/strutil.Po' tmpdepfile='$(DEPDIR)/strutil.TPo' @AMDEPBACKSLASH@ |
|
315 |
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
316 |
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strutil.o `test -f '$(top_srcdir)/shared/strutil.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/strutil.c |
|
317 |
+ |
|
318 |
+strutil.obj: $(top_srcdir)/shared/strutil.c |
|
319 |
+@AMDEP_TRUE@ source='$(top_srcdir)/shared/strutil.c' object='strutil.obj' libtool=no @AMDEPBACKSLASH@ |
|
320 |
+@AMDEP_TRUE@ depfile='$(DEPDIR)/strutil.Po' tmpdepfile='$(DEPDIR)/strutil.TPo' @AMDEPBACKSLASH@ |
|
321 |
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
322 |
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strutil.obj `cygpath -w $(top_srcdir)/shared/strutil.c` |
|
323 |
+ |
|
324 |
+strutil.lo: $(top_srcdir)/shared/strutil.c |
|
325 |
+@AMDEP_TRUE@ source='$(top_srcdir)/shared/strutil.c' object='strutil.lo' libtool=yes @AMDEPBACKSLASH@ |
|
326 |
+@AMDEP_TRUE@ depfile='$(DEPDIR)/strutil.Plo' tmpdepfile='$(DEPDIR)/strutil.TPlo' @AMDEPBACKSLASH@ |
|
327 |
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
328 |
+ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strutil.lo `test -f '$(top_srcdir)/shared/strutil.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/strutil.c |
|
311 | 329 |
CCDEPMODE = @CCDEPMODE@ |
312 | 330 |
|
313 | 331 |
mostlyclean-libtool: |
... | ... |
@@ -317,6 +317,9 @@ |
317 | 317 |
* |
318 | 318 |
* Change History: |
319 | 319 |
* $Log: clamav-milter.c,v $ |
320 |
+ * Revision 1.69 2004/04/06 12:14:52 kojm |
|
321 |
+ * use strlcpy/strlcat |
|
322 |
+ * |
|
320 | 323 |
* Revision 1.68 2004/04/03 04:47:22 nigelhorne |
321 | 324 |
* Honour StreamMaxLength |
322 | 325 |
* |
... | ... |
@@ -506,7 +509,7 @@ |
506 | 506 |
* Revision 1.6 2003/09/28 16:37:23 nigelhorne |
507 | 507 |
* Added -f flag use MaxThreads if --max-children not set |
508 | 508 |
*/ |
509 |
-static char const rcsid[] = "$Id: clamav-milter.c,v 1.68 2004/04/03 04:47:22 nigelhorne Exp $"; |
|
509 |
+static char const rcsid[] = "$Id: clamav-milter.c,v 1.69 2004/04/06 12:14:52 kojm Exp $"; |
|
510 | 510 |
|
511 | 511 |
#define CM_VERSION "0.70g" |
512 | 512 |
|
... | ... |
@@ -522,6 +525,7 @@ static char const rcsid[] = "$Id: clamav-milter.c,v 1.68 2004/04/03 04:47:22 nig |
522 | 522 |
#include "str.h" |
523 | 523 |
#include "../libclamav/others.h" |
524 | 524 |
#include "clamav.h" |
525 |
+#include "strutil.h" |
|
525 | 526 |
|
526 | 527 |
#ifndef CL_DEBUG |
527 | 528 |
#define NDEBUG |
... | ... |
@@ -1295,7 +1299,7 @@ pingServer(int serverNumber) |
1295 | 1295 |
|
1296 | 1296 |
memset((char *)&server, 0, sizeof(struct sockaddr_un)); |
1297 | 1297 |
server.sun_family = AF_UNIX; |
1298 |
- strncpy(server.sun_path, localSocket, sizeof(server.sun_path)); |
|
1298 |
+ strlcpy(server.sun_path, localSocket, sizeof(server.sun_path)); |
|
1299 | 1299 |
|
1300 | 1300 |
if((sock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { |
1301 | 1301 |
perror("socket"); |
... | ... |
@@ -1908,7 +1912,7 @@ clamfi_eom(SMFICTX *ctx) |
1908 | 1908 |
|
1909 | 1909 |
memset((char *)&server, 0, sizeof(struct sockaddr_un)); |
1910 | 1910 |
server.sun_family = AF_UNIX; |
1911 |
- strncpy(server.sun_path, localSocket, sizeof(server.sun_path)); |
|
1911 |
+ strlcpy(server.sun_path, localSocket, sizeof(server.sun_path)); |
|
1912 | 1912 |
|
1913 | 1913 |
if((privdata->cmdSocket = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { |
1914 | 1914 |
perror("socket"); |
... | ... |
@@ -2579,7 +2583,7 @@ connect2clamd(struct privdata *privdata) |
2579 | 2579 |
|
2580 | 2580 |
memset((char *)&server, 0, sizeof(struct sockaddr_un)); |
2581 | 2581 |
server.sun_family = AF_UNIX; |
2582 |
- strncpy(server.sun_path, localSocket, sizeof(server.sun_path)); |
|
2582 |
+ strlcpy(server.sun_path, localSocket, sizeof(server.sun_path)); |
|
2583 | 2583 |
|
2584 | 2584 |
if((privdata->cmdSocket = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { |
2585 | 2585 |
perror("socket"); |
... | ... |
@@ -127,6 +127,8 @@ install_sh = @install_sh@ |
127 | 127 |
@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/getopt.h \ |
128 | 128 |
@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/memory.c \ |
129 | 129 |
@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/memory.h \ |
130 |
+@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/strutil.c \ |
|
131 |
+@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/strutil.h \ |
|
130 | 132 |
@BUILD_CLAMD_TRUE@ options.c \ |
131 | 133 |
@BUILD_CLAMD_TRUE@ options.h \ |
132 | 134 |
@BUILD_CLAMD_TRUE@ clamd.c \ |
... | ... |
@@ -171,12 +173,13 @@ PROGRAMS = $(sbin_PROGRAMS) |
171 | 171 |
|
172 | 172 |
@BUILD_CLAMD_TRUE@am_clamd_OBJECTS = output.$(OBJEXT) \ |
173 | 173 |
@BUILD_CLAMD_TRUE@ cfgparser.$(OBJEXT) getopt.$(OBJEXT) \ |
174 |
-@BUILD_CLAMD_TRUE@ memory.$(OBJEXT) options.$(OBJEXT) \ |
|
175 |
-@BUILD_CLAMD_TRUE@ clamd.$(OBJEXT) tcpserver.$(OBJEXT) \ |
|
176 |
-@BUILD_CLAMD_TRUE@ localserver.$(OBJEXT) session.$(OBJEXT) \ |
|
177 |
-@BUILD_CLAMD_TRUE@ thrmgr.$(OBJEXT) server-th.$(OBJEXT) \ |
|
178 |
-@BUILD_CLAMD_TRUE@ scanner.$(OBJEXT) others.$(OBJEXT) \ |
|
179 |
-@BUILD_CLAMD_TRUE@ clamuko.$(OBJEXT) dazukoio_compat12.$(OBJEXT) \ |
|
174 |
+@BUILD_CLAMD_TRUE@ memory.$(OBJEXT) strutil.$(OBJEXT) \ |
|
175 |
+@BUILD_CLAMD_TRUE@ options.$(OBJEXT) clamd.$(OBJEXT) \ |
|
176 |
+@BUILD_CLAMD_TRUE@ tcpserver.$(OBJEXT) localserver.$(OBJEXT) \ |
|
177 |
+@BUILD_CLAMD_TRUE@ session.$(OBJEXT) thrmgr.$(OBJEXT) \ |
|
178 |
+@BUILD_CLAMD_TRUE@ server-th.$(OBJEXT) scanner.$(OBJEXT) \ |
|
179 |
+@BUILD_CLAMD_TRUE@ others.$(OBJEXT) clamuko.$(OBJEXT) \ |
|
180 |
+@BUILD_CLAMD_TRUE@ dazukoio_compat12.$(OBJEXT) \ |
|
180 | 181 |
@BUILD_CLAMD_TRUE@ dazukoio.$(OBJEXT) tests.$(OBJEXT) |
181 | 182 |
clamd_OBJECTS = $(am_clamd_OBJECTS) |
182 | 183 |
clamd_LDADD = $(LDADD) |
... | ... |
@@ -194,8 +197,9 @@ am__depfiles_maybe = depfiles |
194 | 194 |
@AMDEP_TRUE@ ./$(DEPDIR)/memory.Po ./$(DEPDIR)/options.Po \ |
195 | 195 |
@AMDEP_TRUE@ ./$(DEPDIR)/others.Po ./$(DEPDIR)/output.Po \ |
196 | 196 |
@AMDEP_TRUE@ ./$(DEPDIR)/scanner.Po ./$(DEPDIR)/server-th.Po \ |
197 |
-@AMDEP_TRUE@ ./$(DEPDIR)/session.Po ./$(DEPDIR)/tcpserver.Po \ |
|
198 |
-@AMDEP_TRUE@ ./$(DEPDIR)/tests.Po ./$(DEPDIR)/thrmgr.Po |
|
197 |
+@AMDEP_TRUE@ ./$(DEPDIR)/session.Po ./$(DEPDIR)/strutil.Po \ |
|
198 |
+@AMDEP_TRUE@ ./$(DEPDIR)/tcpserver.Po ./$(DEPDIR)/tests.Po \ |
|
199 |
+@AMDEP_TRUE@ ./$(DEPDIR)/thrmgr.Po |
|
199 | 200 |
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
200 | 201 |
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
201 | 202 |
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ |
... | ... |
@@ -248,6 +252,7 @@ output.$(OBJEXT): $(top_srcdir)/shared/output.c |
248 | 248 |
cfgparser.$(OBJEXT): $(top_srcdir)/shared/cfgparser.c |
249 | 249 |
getopt.$(OBJEXT): $(top_srcdir)/shared/getopt.c |
250 | 250 |
memory.$(OBJEXT): $(top_srcdir)/shared/memory.c |
251 |
+strutil.$(OBJEXT): $(top_srcdir)/shared/strutil.c |
|
251 | 252 |
clamd$(EXEEXT): $(clamd_OBJECTS) $(clamd_DEPENDENCIES) |
252 | 253 |
@rm -f clamd$(EXEEXT) |
253 | 254 |
$(LINK) $(clamd_LDFLAGS) $(clamd_OBJECTS) $(clamd_LDADD) $(LIBS) |
... | ... |
@@ -272,6 +277,7 @@ distclean-compile: |
272 | 272 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scanner.Po@am__quote@ |
273 | 273 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/server-th.Po@am__quote@ |
274 | 274 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/session.Po@am__quote@ |
275 |
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strutil.Po@am__quote@ |
|
275 | 276 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpserver.Po@am__quote@ |
276 | 277 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tests.Po@am__quote@ |
277 | 278 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thrmgr.Po@am__quote@ |
... | ... |
@@ -368,6 +374,24 @@ memory.lo: $(top_srcdir)/shared/memory.c |
368 | 368 |
@AMDEP_TRUE@ depfile='$(DEPDIR)/memory.Plo' tmpdepfile='$(DEPDIR)/memory.TPlo' @AMDEPBACKSLASH@ |
369 | 369 |
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
370 | 370 |
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o memory.lo `test -f '$(top_srcdir)/shared/memory.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/memory.c |
371 |
+ |
|
372 |
+strutil.o: $(top_srcdir)/shared/strutil.c |
|
373 |
+@AMDEP_TRUE@ source='$(top_srcdir)/shared/strutil.c' object='strutil.o' libtool=no @AMDEPBACKSLASH@ |
|
374 |
+@AMDEP_TRUE@ depfile='$(DEPDIR)/strutil.Po' tmpdepfile='$(DEPDIR)/strutil.TPo' @AMDEPBACKSLASH@ |
|
375 |
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
376 |
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strutil.o `test -f '$(top_srcdir)/shared/strutil.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/strutil.c |
|
377 |
+ |
|
378 |
+strutil.obj: $(top_srcdir)/shared/strutil.c |
|
379 |
+@AMDEP_TRUE@ source='$(top_srcdir)/shared/strutil.c' object='strutil.obj' libtool=no @AMDEPBACKSLASH@ |
|
380 |
+@AMDEP_TRUE@ depfile='$(DEPDIR)/strutil.Po' tmpdepfile='$(DEPDIR)/strutil.TPo' @AMDEPBACKSLASH@ |
|
381 |
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
382 |
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strutil.obj `cygpath -w $(top_srcdir)/shared/strutil.c` |
|
383 |
+ |
|
384 |
+strutil.lo: $(top_srcdir)/shared/strutil.c |
|
385 |
+@AMDEP_TRUE@ source='$(top_srcdir)/shared/strutil.c' object='strutil.lo' libtool=yes @AMDEPBACKSLASH@ |
|
386 |
+@AMDEP_TRUE@ depfile='$(DEPDIR)/strutil.Plo' tmpdepfile='$(DEPDIR)/strutil.TPlo' @AMDEPBACKSLASH@ |
|
387 |
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
388 |
+ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strutil.lo `test -f '$(top_srcdir)/shared/strutil.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/strutil.c |
|
371 | 389 |
CCDEPMODE = @CCDEPMODE@ |
372 | 390 |
|
373 | 391 |
mostlyclean-libtool: |
... | ... |
@@ -46,6 +46,7 @@ |
46 | 46 |
#include "dazukoio_xp.h" |
47 | 47 |
#include "dazukoio.h" |
48 | 48 |
#include "others.h" |
49 |
+#include "strutil.h" |
|
49 | 50 |
|
50 | 51 |
#if !defined(NO_COMPAT12) |
51 | 52 |
#include "dazukoio_compat12.h" |
... | ... |
@@ -173,12 +174,12 @@ int dazukoRegister_TS(dazuko_id_t **dazuko_id, const char *groupName, const char |
173 | 173 |
|
174 | 174 |
if (strcasecmp(mode, "r") == 0) |
175 | 175 |
{ |
176 |
- strncpy(regMode, "R", sizeof(regMode)); |
|
176 |
+ strlcpy(regMode, "R", sizeof(regMode)); |
|
177 | 177 |
write_mode = 0; |
178 | 178 |
} |
179 | 179 |
else if (strcasecmp(mode, "r+") == 0 || strcasecmp(mode, "rw") == 0) |
180 | 180 |
{ |
181 |
- strncpy(regMode, "RW", sizeof(regMode)); |
|
181 |
+ strlcpy(regMode, "RW", sizeof(regMode)); |
|
182 | 182 |
write_mode = 1; |
183 | 183 |
} |
184 | 184 |
else |
... | ... |
@@ -47,6 +47,7 @@ |
47 | 47 |
#include <unistd.h> |
48 | 48 |
#include <sys/ioctl.h> |
49 | 49 |
#include "dazukoio_compat12.h" |
50 |
+#include "strutil.h" |
|
50 | 51 |
|
51 | 52 |
int dazukoRegister_TS_compat12_wrapper(struct dazuko_id **dazuko_id, const char *groupName) |
52 | 53 |
{ |
... | ... |
@@ -116,7 +117,7 @@ int dazukoRegister_TS_compat12(struct dazuko_id *dazuko, const char *groupName) |
116 | 116 |
memset(opt, 0, sizeof(struct option_compat12)); |
117 | 117 |
|
118 | 118 |
opt->command = REGISTER; |
119 |
- strncpy(opt->buffer, groupName, sizeof(opt->buffer) - 1); |
|
119 |
+ strlcpy(opt->buffer, groupName, sizeof(opt->buffer)); |
|
120 | 120 |
opt->buffer_length = strlen(opt->buffer) + 1; |
121 | 121 |
|
122 | 122 |
if (ioctl(dazuko->device, _IOW(dazuko->dev_major, IOCTL_SET_OPTION, void *), opt) != 0) |
... | ... |
@@ -186,7 +187,7 @@ int dazuko_set_path_compat12(struct dazuko_id *dazuko, const char *path, int com |
186 | 186 |
memset(opt, 0, sizeof(struct option_compat12)); |
187 | 187 |
|
188 | 188 |
opt->command = command; |
189 |
- strncpy(opt->buffer, path, sizeof(opt->buffer) - 1); |
|
189 |
+ strlcpy(opt->buffer, path, sizeof(opt->buffer)); |
|
190 | 190 |
opt->buffer_length = strlen(opt->buffer) + 1; |
191 | 191 |
|
192 | 192 |
if (ioctl(dazuko->device, _IOW(dazuko->dev_major, IOCTL_SET_OPTION, void *), opt) != 0) |
... | ... |
@@ -323,7 +324,7 @@ int dazukoReturnAccess_TS_compat12_wrapper(struct dazuko_id *dazuko, struct dazu |
323 | 323 |
acc_compat12.pid = (*acc)->pid; |
324 | 324 |
if ((*acc)->filename != NULL) |
325 | 325 |
{ |
326 |
- strncpy(acc_compat12.filename, (*acc)->filename, sizeof(acc_compat12.filename) - 1); |
|
326 |
+ strlcpy(acc_compat12.filename, (*acc)->filename, sizeof(acc_compat12.filename)); |
|
327 | 327 |
acc_compat12.filename[sizeof(acc_compat12.filename) - 1] = 0; |
328 | 328 |
} |
329 | 329 |
|
... | ... |
@@ -35,6 +35,7 @@ |
35 | 35 |
#include "others.h" |
36 | 36 |
#include "server.h" |
37 | 37 |
#include "output.h" |
38 |
+#include "strutil.h" |
|
38 | 39 |
|
39 | 40 |
int localserver(const struct optstruct *opt, const struct cfgstruct *copt, struct cl_node *root) |
40 | 41 |
{ |
... | ... |
@@ -46,7 +47,7 @@ int localserver(const struct optstruct *opt, const struct cfgstruct *copt, struc |
46 | 46 |
|
47 | 47 |
memset((char *) &server, 0, sizeof(server)); |
48 | 48 |
server.sun_family = AF_UNIX; |
49 |
- strncpy(server.sun_path, cfgopt(copt, "LocalSocket")->strarg, sizeof(server.sun_path)); |
|
49 |
+ strlcpy(server.sun_path, cfgopt(copt, "LocalSocket")->strarg, sizeof(server.sun_path)); |
|
50 | 50 |
|
51 | 51 |
if((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { |
52 | 52 |
estr = strerror(errno); |
... | ... |
@@ -37,6 +37,7 @@ |
37 | 37 |
#include "others.h" |
38 | 38 |
#include "../libclamav/others.h" |
39 | 39 |
#include "memory.h" |
40 |
+#include "strutil.h" |
|
40 | 41 |
|
41 | 42 |
void clamd(struct optstruct *opt); |
42 | 43 |
|
... | ... |
@@ -104,9 +105,9 @@ int main(int argc, char **argv) |
104 | 104 |
opt->filename=(char*)mcalloc(len + 256, sizeof(char)); |
105 | 105 |
|
106 | 106 |
for(i=optind; i<argc; i++) { |
107 |
- strncat(opt->filename, argv[i], strlen(argv[i])); |
|
107 |
+ strlcat(opt->filename, argv[i], len+256); |
|
108 | 108 |
if(i != argc-1) |
109 |
- strncat(opt->filename, " ", 1); |
|
109 |
+ strlcat(opt->filename, " ", len+256); |
|
110 | 110 |
} |
111 | 111 |
|
112 | 112 |
} |
... | ... |
@@ -125,6 +125,8 @@ install_sh = @install_sh@ |
125 | 125 |
@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/cfgparser.h \ |
126 | 126 |
@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/memory.c \ |
127 | 127 |
@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/memory.h \ |
128 |
+@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/strutil.c \ |
|
129 |
+@BUILD_CLAMD_TRUE@ $(top_srcdir)/shared/strutil.h \ |
|
128 | 130 |
@BUILD_CLAMD_TRUE@ clamdscan.c \ |
129 | 131 |
@BUILD_CLAMD_TRUE@ client.c \ |
130 | 132 |
@BUILD_CLAMD_TRUE@ client.h \ |
... | ... |
@@ -145,7 +147,8 @@ PROGRAMS = $(bin_PROGRAMS) |
145 | 145 |
|
146 | 146 |
@BUILD_CLAMD_TRUE@am_clamdscan_OBJECTS = output.$(OBJEXT) \ |
147 | 147 |
@BUILD_CLAMD_TRUE@ cfgparser.$(OBJEXT) memory.$(OBJEXT) \ |
148 |
-@BUILD_CLAMD_TRUE@ clamdscan.$(OBJEXT) client.$(OBJEXT) |
|
148 |
+@BUILD_CLAMD_TRUE@ strutil.$(OBJEXT) clamdscan.$(OBJEXT) \ |
|
149 |
+@BUILD_CLAMD_TRUE@ client.$(OBJEXT) |
|
149 | 150 |
clamdscan_OBJECTS = $(am_clamdscan_OBJECTS) |
150 | 151 |
@BUILD_CLAMD_TRUE@clamdscan_DEPENDENCIES = \ |
151 | 152 |
@BUILD_CLAMD_TRUE@ $(top_builddir)/clamscan/options.o \ |
... | ... |
@@ -161,7 +164,8 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp |
161 | 161 |
am__depfiles_maybe = depfiles |
162 | 162 |
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/cfgparser.Po \ |
163 | 163 |
@AMDEP_TRUE@ ./$(DEPDIR)/clamdscan.Po ./$(DEPDIR)/client.Po \ |
164 |
-@AMDEP_TRUE@ ./$(DEPDIR)/memory.Po ./$(DEPDIR)/output.Po |
|
164 |
+@AMDEP_TRUE@ ./$(DEPDIR)/memory.Po ./$(DEPDIR)/output.Po \ |
|
165 |
+@AMDEP_TRUE@ ./$(DEPDIR)/strutil.Po |
|
165 | 166 |
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
166 | 167 |
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
167 | 168 |
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ |
... | ... |
@@ -213,6 +217,7 @@ clean-binPROGRAMS: |
213 | 213 |
output.$(OBJEXT): $(top_srcdir)/shared/output.c |
214 | 214 |
cfgparser.$(OBJEXT): $(top_srcdir)/shared/cfgparser.c |
215 | 215 |
memory.$(OBJEXT): $(top_srcdir)/shared/memory.c |
216 |
+strutil.$(OBJEXT): $(top_srcdir)/shared/strutil.c |
|
216 | 217 |
clamdscan$(EXEEXT): $(clamdscan_OBJECTS) $(clamdscan_DEPENDENCIES) |
217 | 218 |
@rm -f clamdscan$(EXEEXT) |
218 | 219 |
$(LINK) $(clamdscan_LDFLAGS) $(clamdscan_OBJECTS) $(clamdscan_LDADD) $(LIBS) |
... | ... |
@@ -228,6 +233,7 @@ distclean-compile: |
228 | 228 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/client.Po@am__quote@ |
229 | 229 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memory.Po@am__quote@ |
230 | 230 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/output.Po@am__quote@ |
231 |
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strutil.Po@am__quote@ |
|
231 | 232 |
|
232 | 233 |
distclean-depend: |
233 | 234 |
-rm -rf ./$(DEPDIR) |
... | ... |
@@ -303,6 +309,24 @@ memory.lo: $(top_srcdir)/shared/memory.c |
303 | 303 |
@AMDEP_TRUE@ depfile='$(DEPDIR)/memory.Plo' tmpdepfile='$(DEPDIR)/memory.TPlo' @AMDEPBACKSLASH@ |
304 | 304 |
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
305 | 305 |
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o memory.lo `test -f '$(top_srcdir)/shared/memory.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/memory.c |
306 |
+ |
|
307 |
+strutil.o: $(top_srcdir)/shared/strutil.c |
|
308 |
+@AMDEP_TRUE@ source='$(top_srcdir)/shared/strutil.c' object='strutil.o' libtool=no @AMDEPBACKSLASH@ |
|
309 |
+@AMDEP_TRUE@ depfile='$(DEPDIR)/strutil.Po' tmpdepfile='$(DEPDIR)/strutil.TPo' @AMDEPBACKSLASH@ |
|
310 |
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
311 |
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strutil.o `test -f '$(top_srcdir)/shared/strutil.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/strutil.c |
|
312 |
+ |
|
313 |
+strutil.obj: $(top_srcdir)/shared/strutil.c |
|
314 |
+@AMDEP_TRUE@ source='$(top_srcdir)/shared/strutil.c' object='strutil.obj' libtool=no @AMDEPBACKSLASH@ |
|
315 |
+@AMDEP_TRUE@ depfile='$(DEPDIR)/strutil.Po' tmpdepfile='$(DEPDIR)/strutil.TPo' @AMDEPBACKSLASH@ |
|
316 |
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
317 |
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strutil.obj `cygpath -w $(top_srcdir)/shared/strutil.c` |
|
318 |
+ |
|
319 |
+strutil.lo: $(top_srcdir)/shared/strutil.c |
|
320 |
+@AMDEP_TRUE@ source='$(top_srcdir)/shared/strutil.c' object='strutil.lo' libtool=yes @AMDEPBACKSLASH@ |
|
321 |
+@AMDEP_TRUE@ depfile='$(DEPDIR)/strutil.Plo' tmpdepfile='$(DEPDIR)/strutil.TPlo' @AMDEPBACKSLASH@ |
|
322 |
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
323 |
+ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strutil.lo `test -f '$(top_srcdir)/shared/strutil.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/strutil.c |
|
306 | 324 |
CCDEPMODE = @CCDEPMODE@ |
307 | 325 |
|
308 | 326 |
mostlyclean-libtool: |
... | ... |
@@ -38,6 +38,7 @@ |
38 | 38 |
#include "cfgparser.h" |
39 | 39 |
#include "memory.h" |
40 | 40 |
#include "output.h" |
41 |
+#include "strutil.h" |
|
41 | 42 |
|
42 | 43 |
#ifdef PF_INET |
43 | 44 |
# define SOCKET_INET PF_INET |
... | ... |
@@ -78,7 +79,7 @@ int client(const struct optstruct *opt) |
78 | 78 |
} else if((cpt = cfgopt(copt, "LocalSocket"))) { |
79 | 79 |
|
80 | 80 |
server.sun_family = AF_UNIX; |
81 |
- strncpy(server.sun_path, cpt->strarg, sizeof(server.sun_path)); |
|
81 |
+ strlcpy(server.sun_path, cpt->strarg, sizeof(server.sun_path)); |
|
82 | 82 |
|
83 | 83 |
if((sockd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { |
84 | 84 |
perror("socket()"); |
... | ... |
@@ -126,6 +126,8 @@ clamscan_SOURCES = \ |
126 | 126 |
$(top_srcdir)/shared/getopt.h \ |
127 | 127 |
$(top_srcdir)/shared/memory.c \ |
128 | 128 |
$(top_srcdir)/shared/memory.h \ |
129 |
+ $(top_srcdir)/shared/strutil.c \ |
|
130 |
+ $(top_srcdir)/shared/strutil.h \ |
|
129 | 131 |
clamscan.c \ |
130 | 132 |
options.c \ |
131 | 133 |
options.h \ |
... | ... |
@@ -150,8 +152,8 @@ bin_PROGRAMS = clamscan$(EXEEXT) |
150 | 150 |
PROGRAMS = $(bin_PROGRAMS) |
151 | 151 |
|
152 | 152 |
am_clamscan_OBJECTS = output.$(OBJEXT) getopt.$(OBJEXT) memory.$(OBJEXT) \ |
153 |
- clamscan.$(OBJEXT) options.$(OBJEXT) others.$(OBJEXT) \ |
|
154 |
- manager.$(OBJEXT) treewalk.$(OBJEXT) |
|
153 |
+ strutil.$(OBJEXT) clamscan.$(OBJEXT) options.$(OBJEXT) \ |
|
154 |
+ others.$(OBJEXT) manager.$(OBJEXT) treewalk.$(OBJEXT) |
|
155 | 155 |
clamscan_OBJECTS = $(am_clamscan_OBJECTS) |
156 | 156 |
clamscan_LDADD = $(LDADD) |
157 | 157 |
clamscan_DEPENDENCIES = |
... | ... |
@@ -164,7 +166,8 @@ am__depfiles_maybe = depfiles |
164 | 164 |
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/clamscan.Po ./$(DEPDIR)/getopt.Po \ |
165 | 165 |
@AMDEP_TRUE@ ./$(DEPDIR)/manager.Po ./$(DEPDIR)/memory.Po \ |
166 | 166 |
@AMDEP_TRUE@ ./$(DEPDIR)/options.Po ./$(DEPDIR)/others.Po \ |
167 |
-@AMDEP_TRUE@ ./$(DEPDIR)/output.Po ./$(DEPDIR)/treewalk.Po |
|
167 |
+@AMDEP_TRUE@ ./$(DEPDIR)/output.Po ./$(DEPDIR)/strutil.Po \ |
|
168 |
+@AMDEP_TRUE@ ./$(DEPDIR)/treewalk.Po |
|
168 | 169 |
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
169 | 170 |
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
170 | 171 |
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ |
... | ... |
@@ -216,6 +219,7 @@ clean-binPROGRAMS: |
216 | 216 |
output.$(OBJEXT): $(top_srcdir)/shared/output.c |
217 | 217 |
getopt.$(OBJEXT): $(top_srcdir)/shared/getopt.c |
218 | 218 |
memory.$(OBJEXT): $(top_srcdir)/shared/memory.c |
219 |
+strutil.$(OBJEXT): $(top_srcdir)/shared/strutil.c |
|
219 | 220 |
clamscan$(EXEEXT): $(clamscan_OBJECTS) $(clamscan_DEPENDENCIES) |
220 | 221 |
@rm -f clamscan$(EXEEXT) |
221 | 222 |
$(LINK) $(clamscan_LDFLAGS) $(clamscan_OBJECTS) $(clamscan_LDADD) $(LIBS) |
... | ... |
@@ -233,6 +237,7 @@ distclean-compile: |
233 | 233 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@ |
234 | 234 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/others.Po@am__quote@ |
235 | 235 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/output.Po@am__quote@ |
236 |
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strutil.Po@am__quote@ |
|
236 | 237 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/treewalk.Po@am__quote@ |
237 | 238 |
|
238 | 239 |
distclean-depend: |
... | ... |
@@ -309,6 +314,24 @@ memory.lo: $(top_srcdir)/shared/memory.c |
309 | 309 |
@AMDEP_TRUE@ depfile='$(DEPDIR)/memory.Plo' tmpdepfile='$(DEPDIR)/memory.TPlo' @AMDEPBACKSLASH@ |
310 | 310 |
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
311 | 311 |
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o memory.lo `test -f '$(top_srcdir)/shared/memory.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/memory.c |
312 |
+ |
|
313 |
+strutil.o: $(top_srcdir)/shared/strutil.c |
|
314 |
+@AMDEP_TRUE@ source='$(top_srcdir)/shared/strutil.c' object='strutil.o' libtool=no @AMDEPBACKSLASH@ |
|
315 |
+@AMDEP_TRUE@ depfile='$(DEPDIR)/strutil.Po' tmpdepfile='$(DEPDIR)/strutil.TPo' @AMDEPBACKSLASH@ |
|
316 |
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
317 |
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strutil.o `test -f '$(top_srcdir)/shared/strutil.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/strutil.c |
|
318 |
+ |
|
319 |
+strutil.obj: $(top_srcdir)/shared/strutil.c |
|
320 |
+@AMDEP_TRUE@ source='$(top_srcdir)/shared/strutil.c' object='strutil.obj' libtool=no @AMDEPBACKSLASH@ |
|
321 |
+@AMDEP_TRUE@ depfile='$(DEPDIR)/strutil.Po' tmpdepfile='$(DEPDIR)/strutil.TPo' @AMDEPBACKSLASH@ |
|
322 |
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
323 |
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strutil.obj `cygpath -w $(top_srcdir)/shared/strutil.c` |
|
324 |
+ |
|
325 |
+strutil.lo: $(top_srcdir)/shared/strutil.c |
|
326 |
+@AMDEP_TRUE@ source='$(top_srcdir)/shared/strutil.c' object='strutil.lo' libtool=yes @AMDEPBACKSLASH@ |
|
327 |
+@AMDEP_TRUE@ depfile='$(DEPDIR)/strutil.Plo' tmpdepfile='$(DEPDIR)/strutil.TPlo' @AMDEPBACKSLASH@ |
|
328 |
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
329 |
+ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strutil.lo `test -f '$(top_srcdir)/shared/strutil.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/strutil.c |
|
312 | 330 |
CCDEPMODE = @CCDEPMODE@ |
313 | 331 |
|
314 | 332 |
mostlyclean-libtool: |
... | ... |
@@ -49,6 +49,7 @@ |
49 | 49 |
#include "strrcpy.h" |
50 | 50 |
#include "memory.h" |
51 | 51 |
#include "output.h" |
52 |
+#include "strutil.h" |
|
52 | 53 |
|
53 | 54 |
#ifdef C_LINUX |
54 | 55 |
dev_t procdev; |
... | ... |
@@ -133,7 +134,7 @@ int scanmanager(const struct optstruct *opt) |
133 | 133 |
ptr = getargl(opt, "max-space"); |
134 | 134 |
if(tolower(ptr[strlen(ptr) - 1]) == 'm') { |
135 | 135 |
cpy = mcalloc(strlen(ptr), sizeof(char)); |
136 |
- strncpy(cpy, ptr, strlen(ptr) - 1); |
|
136 |
+ strlcpy(cpy, ptr, strlen(ptr)); |
|
137 | 137 |
limits->maxfilesize = atoi(cpy) * 1024 * 1024; |
138 | 138 |
free(cpy); |
139 | 139 |
} else |
... | ... |
@@ -842,7 +843,7 @@ int clamav_unpack(const char *prog, char **args, const char *tmpdir, const struc |
842 | 842 |
ptr = getargl(opt, "max-space"); |
843 | 843 |
if(tolower(ptr[strlen(ptr) - 1]) == 'm') { /* megabytes */ |
844 | 844 |
cpy = mcalloc(strlen(ptr), sizeof(char)); |
845 |
- strncpy(cpy, ptr, strlen(ptr) - 1); |
|
845 |
+ strlcpy(cpy, ptr, strlen(ptr)); |
|
846 | 846 |
maxspace = atoi(cpy) * 1024; |
847 | 847 |
free(cpy); |
848 | 848 |
} else /* default - kilobytes */ |
... | ... |
@@ -35,6 +35,7 @@ |
35 | 35 |
#include "shared.h" |
36 | 36 |
#include "memory.h" |
37 | 37 |
#include "output.h" |
38 |
+#include "strutil.h" |
|
38 | 39 |
|
39 | 40 |
extern int clamscan(struct optstruct *opt); |
40 | 41 |
|
... | ... |
@@ -138,9 +139,9 @@ int main(int argc, char **argv) |
138 | 138 |
opt->filename=(char*)mcalloc(len + 256, sizeof(char)); |
139 | 139 |
|
140 | 140 |
for(i=optind; i<argc; i++) { |
141 |
- strncat(opt->filename, argv[i], strlen(argv[i])); |
|
141 |
+ strlcat(opt->filename, argv[i], len+256); |
|
142 | 142 |
if(i != argc-1) |
143 |
- strncat(opt->filename, "\t", 1); |
|
143 |
+ strlcat(opt->filename, "\t", len+256); |
|
144 | 144 |
} |
145 | 145 |
|
146 | 146 |
} |
... | ... |
@@ -8231,7 +8231,9 @@ _ACEOF |
8231 | 8231 |
|
8232 | 8232 |
|
8233 | 8233 |
|
8234 |
-for ac_func in poll setsid memcpy snprintf vsnprintf strerror_r |
|
8234 |
+ |
|
8235 |
+ |
|
8236 |
+for ac_func in poll setsid memcpy snprintf vsnprintf strerror_r strlcpy strlcat |
|
8235 | 8237 |
do |
8236 | 8238 |
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` |
8237 | 8239 |
echo "$as_me:$LINENO: checking for $ac_func" >&5 |
... | ... |
@@ -57,7 +57,7 @@ AC_TYPE_OFF_T |
57 | 57 |
AC_COMPILE_CHECK_SIZEOF(short) |
58 | 58 |
AC_COMPILE_CHECK_SIZEOF(int) |
59 | 59 |
AC_COMPILE_CHECK_SIZEOF(long) |
60 |
-AC_CHECK_FUNCS(poll setsid memcpy snprintf vsnprintf strerror_r) |
|
60 |
+AC_CHECK_FUNCS(poll setsid memcpy snprintf vsnprintf strerror_r strlcpy strlcat) |
|
61 | 61 |
|
62 | 62 |
# Check for broken snprintf |
63 | 63 |
if test "x$ac_cv_func_snprintf" = "xyes" ; then |
... | ... |
@@ -128,6 +128,8 @@ freshclam_SOURCES = \ |
128 | 128 |
$(top_srcdir)/shared/getopt.h \ |
129 | 129 |
$(top_srcdir)/shared/memory.c \ |
130 | 130 |
$(top_srcdir)/shared/memory.h \ |
131 |
+ $(top_srcdir)/shared/strutil.c \ |
|
132 |
+ $(top_srcdir)/shared/strutil.h \ |
|
131 | 133 |
freshclam.c \ |
132 | 134 |
freshclam.h \ |
133 | 135 |
options.c \ |
... | ... |
@@ -150,8 +152,9 @@ bin_PROGRAMS = freshclam$(EXEEXT) |
150 | 150 |
PROGRAMS = $(bin_PROGRAMS) |
151 | 151 |
|
152 | 152 |
am_freshclam_OBJECTS = output.$(OBJEXT) cfgparser.$(OBJEXT) \ |
153 |
- getopt.$(OBJEXT) memory.$(OBJEXT) freshclam.$(OBJEXT) \ |
|
154 |
- options.$(OBJEXT) manager.$(OBJEXT) notify.$(OBJEXT) |
|
153 |
+ getopt.$(OBJEXT) memory.$(OBJEXT) strutil.$(OBJEXT) \ |
|
154 |
+ freshclam.$(OBJEXT) options.$(OBJEXT) manager.$(OBJEXT) \ |
|
155 |
+ notify.$(OBJEXT) |
|
155 | 156 |
freshclam_OBJECTS = $(am_freshclam_OBJECTS) |
156 | 157 |
freshclam_LDADD = $(LDADD) |
157 | 158 |
freshclam_DEPENDENCIES = |
... | ... |
@@ -165,7 +168,7 @@ am__depfiles_maybe = depfiles |
165 | 165 |
@AMDEP_TRUE@ ./$(DEPDIR)/freshclam.Po ./$(DEPDIR)/getopt.Po \ |
166 | 166 |
@AMDEP_TRUE@ ./$(DEPDIR)/manager.Po ./$(DEPDIR)/memory.Po \ |
167 | 167 |
@AMDEP_TRUE@ ./$(DEPDIR)/notify.Po ./$(DEPDIR)/options.Po \ |
168 |
-@AMDEP_TRUE@ ./$(DEPDIR)/output.Po |
|
168 |
+@AMDEP_TRUE@ ./$(DEPDIR)/output.Po ./$(DEPDIR)/strutil.Po |
|
169 | 169 |
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
170 | 170 |
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
171 | 171 |
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ |
... | ... |
@@ -218,6 +221,7 @@ output.$(OBJEXT): $(top_srcdir)/shared/output.c |
218 | 218 |
cfgparser.$(OBJEXT): $(top_srcdir)/shared/cfgparser.c |
219 | 219 |
getopt.$(OBJEXT): $(top_srcdir)/shared/getopt.c |
220 | 220 |
memory.$(OBJEXT): $(top_srcdir)/shared/memory.c |
221 |
+strutil.$(OBJEXT): $(top_srcdir)/shared/strutil.c |
|
221 | 222 |
freshclam$(EXEEXT): $(freshclam_OBJECTS) $(freshclam_DEPENDENCIES) |
222 | 223 |
@rm -f freshclam$(EXEEXT) |
223 | 224 |
$(LINK) $(freshclam_LDFLAGS) $(freshclam_OBJECTS) $(freshclam_LDADD) $(LIBS) |
... | ... |
@@ -236,6 +240,7 @@ distclean-compile: |
236 | 236 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/notify.Po@am__quote@ |
237 | 237 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@ |
238 | 238 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/output.Po@am__quote@ |
239 |
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strutil.Po@am__quote@ |
|
239 | 240 |
|
240 | 241 |
distclean-depend: |
241 | 242 |
-rm -rf ./$(DEPDIR) |
... | ... |
@@ -329,6 +334,24 @@ memory.lo: $(top_srcdir)/shared/memory.c |
329 | 329 |
@AMDEP_TRUE@ depfile='$(DEPDIR)/memory.Plo' tmpdepfile='$(DEPDIR)/memory.TPlo' @AMDEPBACKSLASH@ |
330 | 330 |
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
331 | 331 |
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o memory.lo `test -f '$(top_srcdir)/shared/memory.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/memory.c |
332 |
+ |
|
333 |
+strutil.o: $(top_srcdir)/shared/strutil.c |
|
334 |
+@AMDEP_TRUE@ source='$(top_srcdir)/shared/strutil.c' object='strutil.o' libtool=no @AMDEPBACKSLASH@ |
|
335 |
+@AMDEP_TRUE@ depfile='$(DEPDIR)/strutil.Po' tmpdepfile='$(DEPDIR)/strutil.TPo' @AMDEPBACKSLASH@ |
|
336 |
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
337 |
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strutil.o `test -f '$(top_srcdir)/shared/strutil.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/strutil.c |
|
338 |
+ |
|
339 |
+strutil.obj: $(top_srcdir)/shared/strutil.c |
|
340 |
+@AMDEP_TRUE@ source='$(top_srcdir)/shared/strutil.c' object='strutil.obj' libtool=no @AMDEPBACKSLASH@ |
|
341 |
+@AMDEP_TRUE@ depfile='$(DEPDIR)/strutil.Po' tmpdepfile='$(DEPDIR)/strutil.TPo' @AMDEPBACKSLASH@ |
|
342 |
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
343 |
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strutil.obj `cygpath -w $(top_srcdir)/shared/strutil.c` |
|
344 |
+ |
|
345 |
+strutil.lo: $(top_srcdir)/shared/strutil.c |
|
346 |
+@AMDEP_TRUE@ source='$(top_srcdir)/shared/strutil.c' object='strutil.lo' libtool=yes @AMDEPBACKSLASH@ |
|
347 |
+@AMDEP_TRUE@ depfile='$(DEPDIR)/strutil.Plo' tmpdepfile='$(DEPDIR)/strutil.TPlo' @AMDEPBACKSLASH@ |
|
348 |
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
349 |
+ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strutil.lo `test -f '$(top_srcdir)/shared/strutil.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/strutil.c |
|
332 | 350 |
CCDEPMODE = @CCDEPMODE@ |
333 | 351 |
|
334 | 352 |
mostlyclean-libtool: |
... | ... |
@@ -57,7 +57,7 @@ int notify(const char *cfgfile) |
57 | 57 |
} else if((cpt = cfgopt(copt, "LocalSocket"))) { |
58 | 58 |
socktype = "UNIX"; |
59 | 59 |
server.sun_family = AF_UNIX; |
60 |
- strncpy(server.sun_path, cpt->strarg, sizeof(server.sun_path)); |
|
60 |
+ strlcpy(server.sun_path, cpt->strarg, sizeof(server.sun_path)); |
|
61 | 61 |
|
62 | 62 |
if((sockd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { |
63 | 63 |
mprintf("@Clamd was NOT notified: Can't create socket endpoint for %s\n", cpt->strarg); |
... | ... |
@@ -107,9 +107,9 @@ int main(int argc, char **argv) |
107 | 107 |
opt->filename=(char*)mcalloc(len + 256, sizeof(char)); |
108 | 108 |
|
109 | 109 |
for(i=optind; i<argc; i++) { |
110 |
- strncat(opt->filename, argv[i], strlen(argv[i])); |
|
110 |
+ strlcat(opt->filename, argv[i], len+256); |
|
111 | 111 |
if(i != argc-1) |
112 |
- strncat(opt->filename, " ", 1); |
|
112 |
+ strlcat(opt->filename, " ", len+256); |
|
113 | 113 |
} |
114 | 114 |
|
115 | 115 |
} |
... | ... |
@@ -116,7 +116,7 @@ am__include = @am__include@ |
116 | 116 |
am__quote = @am__quote@ |
117 | 117 |
install_sh = @install_sh@ |
118 | 118 |
|
119 |
-INCLUDES = -I$(top_srcdir) -I@srcdir@/zziplib |
|
119 |
+INCLUDES = -I$(top_srcdir) -I@srcdir@/zziplib -I$(top_srcdir)/shared |
|
120 | 120 |
|
121 | 121 |
libclamav_la_LIBADD = @LIBCLAMAV_LIBS@ |
122 | 122 |
|
... | ... |
@@ -34,6 +34,7 @@ |
34 | 34 |
#include "others.h" |
35 | 35 |
#include "dsig.h" |
36 | 36 |
#include "str.h" |
37 |
+#include "strutil.h" |
|
37 | 38 |
|
38 | 39 |
#define TAR_BLOCKSIZE 512 |
39 | 40 |
|
... | ... |
@@ -74,8 +75,7 @@ int cli_untgz(int fd, const char *destdir) |
74 | 74 |
if (block[0] == '\0') /* We're done */ |
75 | 75 |
break; |
76 | 76 |
|
77 |
- strncpy(name, block, 100); |
|
78 |
- name[100] = '\0'; |
|
77 |
+ strlcpy(name, block, 101); |
|
79 | 78 |
strcpy(fullname, destdir); |
80 | 79 |
strcat(fullname, "/"); |
81 | 80 |
strcat(fullname, name); |
... | ... |
@@ -117,8 +117,7 @@ int cli_untgz(int fd, const char *destdir) |
117 | 117 |
return -1; |
118 | 118 |
} |
119 | 119 |
|
120 |
- strncpy(osize, block + 124, 12); |
|
121 |
- osize[12] = '\0'; |
|
120 |
+ strlcpy(osize, block + 124, 13); |
|
122 | 121 |
|
123 | 122 |
if((sscanf(osize, "%o", &size)) == 0) { |
124 | 123 |
cli_errmsg("Invalid size in header.\n"); |
... | ... |
@@ -47,6 +47,7 @@ pthread_mutex_t cl_gentemp_mutex = PTHREAD_MUTEX_INITIALIZER; |
47 | 47 |
#include "clamav.h" |
48 | 48 |
#include "others.h" |
49 | 49 |
#include "md5.h" |
50 |
+#include "strutil.h" |
|
50 | 51 |
|
51 | 52 |
#define CL_FLEVEL 1 /* don't touch it */ |
52 | 53 |
|
... | ... |
@@ -299,7 +300,7 @@ char *cl_gentemp(const char *dir) |
299 | 299 |
|
300 | 300 |
tmp = cl_md5buff(( char* ) salt, 48); |
301 | 301 |
sprintf(name, "%s/", mdir); |
302 |
- strncat(name, tmp, 16); |
|
302 |
+ strlcat(name, tmp, strlen(mdir) + 1 + 16 + 1); |
|
303 | 303 |
free(tmp); |
304 | 304 |
} while(stat(name, &foo) != -1); |
305 | 305 |
|
... | ... |
@@ -37,6 +37,7 @@ |
37 | 37 |
#include "others.h" |
38 | 38 |
#include "str.h" |
39 | 39 |
#include "defaults.h" |
40 |
+#include "strutil.h" |
|
40 | 41 |
|
41 | 42 |
static int cli_parse_add(struct cl_node *root, const char *virname, const char *hexstr, int sigid, int parts, int partno) |
42 | 43 |
{ |
... | ... |
@@ -78,7 +79,7 @@ static int cli_parse_add(struct cl_node *root, const char *virname, const char * |
78 | 78 |
return CL_EMEM; |
79 | 79 |
} |
80 | 80 |
|
81 |
- strncpy(new->virname, virname, virlen); |
|
81 |
+ strlcpy(new->virname, virname, virlen); |
|
82 | 82 |
|
83 | 83 |
if((ret = cli_addpatt(root, new))) { |
84 | 84 |
free(new->virname); |
... | ... |
@@ -30,6 +30,7 @@ |
30 | 30 |
#include "clamav.h" |
31 | 31 |
#include "others.h" |
32 | 32 |
#include "defaults.h" |
33 |
+#include "strutil.h" |
|
33 | 34 |
|
34 | 35 |
static int cli_hex2int(int c) |
35 | 36 |
{ |
... | ... |
@@ -179,8 +180,7 @@ char *cli_strtok(const char *line, int fieldno, const char *delim) |
179 | 179 |
return NULL; |
180 | 180 |
} |
181 | 181 |
buffer = malloc(j-i+1); |
182 |
- strncpy(buffer, line+i, j-i); |
|
183 |
- buffer[j-i] = '\0'; |
|
182 |
+ strlcpy(buffer, line+i, j-i+1); |
|
184 | 183 |
|
185 | 184 |
return buffer; |
186 | 185 |
} |
... | ... |
@@ -69,6 +69,7 @@ |
69 | 69 |
|
70 | 70 |
#include "unrarlib.h" /* include global configuration */ |
71 | 71 |
#include "others.h" |
72 |
+#include "strutil.h" |
|
72 | 73 |
/* ------------------------------------------------------------------------ */ |
73 | 74 |
|
74 | 75 |
|
... | ... |
@@ -1180,8 +1181,8 @@ int stricomp(char *Str1,char *Str2) |
1180 | 1180 |
char S1[512],S2[512]; |
1181 | 1181 |
char *chptr; |
1182 | 1182 |
|
1183 |
- strncpy(S1,Str1,sizeof(S1)); |
|
1184 |
- strncpy(S2,Str2,sizeof(S2)); |
|
1183 |
+ strlcpy(S1,Str1,sizeof(S1)); |
|
1184 |
+ strlcpy(S2,Str2,sizeof(S2)); |
|
1185 | 1185 |
|
1186 | 1186 |
while((chptr = strchr(S1, '\\')) != NULL) /* ignore backslash */ |
1187 | 1187 |
{ |
... | ... |
@@ -20,6 +20,7 @@ |
20 | 20 |
#include <stdlib.h> |
21 | 21 |
#include <string.h> |
22 | 22 |
#include <errno.h> |
23 |
+#include "strutil.h" |
|
23 | 24 |
|
24 | 25 |
#ifdef ZZIP_HAVE_SYS_STAT_H |
25 | 26 |
#include <sys/stat.h> |
... | ... |
@@ -83,9 +84,9 @@ real_readdir(ZZIP_DIR* dir) |
83 | 83 |
if (! dirent) return 0; |
84 | 84 |
|
85 | 85 |
dir->dirent.d_name = dirent->d_name; |
86 |
- strcpy(filename, dir->realname); |
|
87 |
- strcat(filename, "/"); |
|
88 |
- strcat(filename, dirent->d_name); |
|
86 |
+ strlcpy(filename, dir->realname, PATH_MAX); |
|
87 |
+ strlcat(filename, "/", PATH_MAX); |
|
88 |
+ strlcat(filename, dirent->d_name, PATH_MAX); |
|
89 | 89 |
|
90 | 90 |
if (stat(filename, &st) == -1) |
91 | 91 |
return -1; |
... | ... |
@@ -30,6 +30,7 @@ |
30 | 30 |
#include "defaults.h" |
31 | 31 |
#include "str.h" |
32 | 32 |
#include "memory.h" |
33 |
+#include "strutil.h" |
|
33 | 34 |
|
34 | 35 |
static int isnumb(const char *str) |
35 | 36 |
{ |
... | ... |
@@ -176,7 +177,7 @@ struct cfgstruct *parsecfg(const char *cfgfile) |
176 | 176 |
ctype = tolower(arg[strlen(arg) - 1]); |
177 | 177 |
if(ctype == 'm' || ctype == 'k') { |
178 | 178 |
char *cpy = (char *) mcalloc(strlen(arg), sizeof(char)); |
179 |
- strncpy(cpy, arg, strlen(arg) - 1); |
|
179 |
+ strlcpy(cpy, arg, strlen(arg)); |
|
180 | 180 |
if(!isnumb(cpy)) { |
181 | 181 |
fprintf(stderr, "ERROR: Parse error at line %d: Option %s requires numerical (raw/K/M) argument.\n", line, name); |
182 | 182 |
return NULL; |
... | ... |
@@ -42,6 +42,7 @@ |
42 | 42 |
|
43 | 43 |
#include "output.h" |
44 | 44 |
#include "memory.h" |
45 |
+#include "strutil.h" |
|
45 | 46 |
|
46 | 47 |
#ifdef CL_THREAD_SAFE |
47 | 48 |
#include <pthread.h> |
... | ... |
@@ -136,7 +137,7 @@ int logg(const char *str, ...) |
136 | 136 |
time(&currtime); |
137 | 137 |
pt = ctime(&currtime); |
138 | 138 |
timestr = mcalloc(strlen(pt), sizeof(char)); |
139 |
- strncpy(timestr, pt, strlen(pt) - 1); |
|
139 |
+ strlcpy(timestr, pt, strlen(pt)); |
|
140 | 140 |
fprintf(logg_fd, "%s -> ", timestr); |
141 | 141 |
free(timestr); |
142 | 142 |
} |
143 | 143 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,55 @@ |
0 |
+/* |
|
1 |
+ * Copyright (C) 2004 Bastian Kleineidam <calvin@debian.org> |
|
2 |
+ * |
|
3 |
+ * This program is free software; you can redistribute it and/or modify |
|
4 |
+ * it under the terms of the GNU General Public License as published by |
|
5 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
6 |
+ * (at your option) any later version. |
|
7 |
+ * |
|
8 |
+ * This program is distributed in the hope that it will be useful, |
|
9 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 |
+ * GNU General Public License for more details. |
|
12 |
+ * |
|
13 |
+ * You should have received a copy of the GNU General Public License |
|
14 |
+ * along with this program; if not, write to the Free Software |
|
15 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
16 |
+ */ |
|
17 |
+ |
|
18 |
+#if HAVE_CONFIG_H |
|
19 |
+#include "clamav-config.h" |
|
20 |
+#endif |
|
21 |
+ |
|
22 |
+#include <string.h> |
|
23 |
+#include <stdlib.h> |
|
24 |
+ |
|
25 |
+#if !defined(HAVE_STRLCPY) |
|
26 |
+size_t strlcpy(char *dst, const char *src, size_t size) |
|
27 |
+{ |
|
28 |
+ size_t ret = strlen(src); |
|
29 |
+ |
|
30 |
+ if (size) { |
|
31 |
+ size_t len = (ret >= size) ? size-1 : ret; |
|
32 |
+ memcpy(dst, src, len); |
|
33 |
+ dst[len] = '\0'; |
|
34 |
+ } |
|
35 |
+ |
|
36 |
+ return ret; |
|
37 |
+} |
|
38 |
+#endif |
|
39 |
+ |
|
40 |
+#if !defined(HAVE_STRLCAT) |
|
41 |
+size_t strlcat(char *dst, const char *src, size_t size) |
|
42 |
+{ |
|
43 |
+ size_t dst_len = strlen(dst); |
|
44 |
+ size_t src_len = strlen(src); |
|
45 |
+ |
|
46 |
+ if (size) { |
|
47 |
+ size_t len = (src_len >= size-dst_len) ? (size-dst_len-1) : src_len; |
|
48 |
+ memcpy(&dst[dst_len], src, len); |
|
49 |
+ dst[dst_len + len] = '\0'; |
|
50 |
+ } |
|
51 |
+ |
|
52 |
+ return dst_len + src_len; |
|
53 |
+} |
|
54 |
+#endif |
0 | 55 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,37 @@ |
0 |
+/* |
|
1 |
+ * Copyright (C) 2004 Bastian Kleineidam <calvin@debian.org> |
|
2 |
+ * |
|
3 |
+ * This program is free software; you can redistribute it and/or modify |
|
4 |
+ * it under the terms of the GNU General Public License as published by |
|
5 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
6 |
+ * (at your option) any later version. |
|
7 |
+ * |
|
8 |
+ * This program is distributed in the hope that it will be useful, |
|
9 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 |
+ * GNU General Public License for more details. |
|
12 |
+ * |
|
13 |
+ * You should have received a copy of the GNU General Public License |
|
14 |
+ * along with this program; if not, write to the Free Software |
|
15 |
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
16 |
+ */ |
|
17 |
+ |
|
18 |
+#ifndef __STRUTIL_H |
|
19 |
+#define __STRUTIL_H |
|
20 |
+ |
|
21 |
+#if HAVE_CONFIG_H |
|
22 |
+#include "clamav-config.h" |
|
23 |
+#endif |
|
24 |
+ |
|
25 |
+#include <string.h> |
|
26 |
+#include <stdlib.h> |
|
27 |
+ |
|
28 |
+#if !defined(HAVE_STRLCPY) |
|
29 |
+size_t strlcpy(char *dst, const char *src, size_t size); |
|
30 |
+#endif |
|
31 |
+ |
|
32 |
+#if !defined(HAVE_STRLCAT) |
|
33 |
+size_t strlcat(char *dst, const char *src, size_t size); |
|
34 |
+#endif |
|
35 |
+ |
|
36 |
+#endif |
... | ... |
@@ -125,6 +125,8 @@ sigtool_SOURCES = \ |
125 | 125 |
$(top_srcdir)/shared/getopt.h \ |
126 | 126 |
$(top_srcdir)/shared/memory.c \ |
127 | 127 |
$(top_srcdir)/shared/memory.h \ |
128 |
+ $(top_srcdir)/shared/strutil.c \ |
|
129 |
+ $(top_srcdir)/shared/strutil.h \ |
|
128 | 130 |
options.c \ |
129 | 131 |
options.h \ |
130 | 132 |
sigtool.c |
... | ... |
@@ -143,7 +145,7 @@ bin_PROGRAMS = sigtool$(EXEEXT) |
143 | 143 |
PROGRAMS = $(bin_PROGRAMS) |
144 | 144 |
|
145 | 145 |
am_sigtool_OBJECTS = output.$(OBJEXT) getopt.$(OBJEXT) memory.$(OBJEXT) \ |
146 |
- options.$(OBJEXT) sigtool.$(OBJEXT) |
|
146 |
+ strutil.$(OBJEXT) options.$(OBJEXT) sigtool.$(OBJEXT) |
|
147 | 147 |
sigtool_OBJECTS = $(am_sigtool_OBJECTS) |
148 | 148 |
sigtool_DEPENDENCIES = $(top_builddir)/clamscan/others.o |
149 | 149 |
sigtool_LDFLAGS = |
... | ... |
@@ -154,7 +156,7 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp |
154 | 154 |
am__depfiles_maybe = depfiles |
155 | 155 |
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/getopt.Po ./$(DEPDIR)/memory.Po \ |
156 | 156 |
@AMDEP_TRUE@ ./$(DEPDIR)/options.Po ./$(DEPDIR)/output.Po \ |
157 |
-@AMDEP_TRUE@ ./$(DEPDIR)/sigtool.Po |
|
157 |
+@AMDEP_TRUE@ ./$(DEPDIR)/sigtool.Po ./$(DEPDIR)/strutil.Po |
|
158 | 158 |
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
159 | 159 |
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
160 | 160 |
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ |
... | ... |
@@ -206,6 +208,7 @@ clean-binPROGRAMS: |
206 | 206 |
output.$(OBJEXT): $(top_srcdir)/shared/output.c |
207 | 207 |
getopt.$(OBJEXT): $(top_srcdir)/shared/getopt.c |
208 | 208 |
memory.$(OBJEXT): $(top_srcdir)/shared/memory.c |
209 |
+strutil.$(OBJEXT): $(top_srcdir)/shared/strutil.c |
|
209 | 210 |
sigtool$(EXEEXT): $(sigtool_OBJECTS) $(sigtool_DEPENDENCIES) |
210 | 211 |
@rm -f sigtool$(EXEEXT) |
211 | 212 |
$(LINK) $(sigtool_LDFLAGS) $(sigtool_OBJECTS) $(sigtool_LDADD) $(LIBS) |
... | ... |
@@ -221,6 +224,7 @@ distclean-compile: |
221 | 221 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@ |
222 | 222 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/output.Po@am__quote@ |
223 | 223 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sigtool.Po@am__quote@ |
224 |
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strutil.Po@am__quote@ |
|
224 | 225 |
|
225 | 226 |
distclean-depend: |
226 | 227 |
-rm -rf ./$(DEPDIR) |
... | ... |
@@ -296,6 +300,24 @@ memory.lo: $(top_srcdir)/shared/memory.c |
296 | 296 |
@AMDEP_TRUE@ depfile='$(DEPDIR)/memory.Plo' tmpdepfile='$(DEPDIR)/memory.TPlo' @AMDEPBACKSLASH@ |
297 | 297 |
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
298 | 298 |
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o memory.lo `test -f '$(top_srcdir)/shared/memory.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/memory.c |
299 |
+ |
|
300 |
+strutil.o: $(top_srcdir)/shared/strutil.c |
|
301 |
+@AMDEP_TRUE@ source='$(top_srcdir)/shared/strutil.c' object='strutil.o' libtool=no @AMDEPBACKSLASH@ |
|
302 |
+@AMDEP_TRUE@ depfile='$(DEPDIR)/strutil.Po' tmpdepfile='$(DEPDIR)/strutil.TPo' @AMDEPBACKSLASH@ |
|
303 |
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
304 |
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strutil.o `test -f '$(top_srcdir)/shared/strutil.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/strutil.c |
|
305 |
+ |
|
306 |
+strutil.obj: $(top_srcdir)/shared/strutil.c |
|
307 |
+@AMDEP_TRUE@ source='$(top_srcdir)/shared/strutil.c' object='strutil.obj' libtool=no @AMDEPBACKSLASH@ |
|
308 |
+@AMDEP_TRUE@ depfile='$(DEPDIR)/strutil.Po' tmpdepfile='$(DEPDIR)/strutil.TPo' @AMDEPBACKSLASH@ |
|
309 |
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
310 |
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strutil.obj `cygpath -w $(top_srcdir)/shared/strutil.c` |
|
311 |
+ |
|
312 |
+strutil.lo: $(top_srcdir)/shared/strutil.c |
|
313 |
+@AMDEP_TRUE@ source='$(top_srcdir)/shared/strutil.c' object='strutil.lo' libtool=yes @AMDEPBACKSLASH@ |
|
314 |
+@AMDEP_TRUE@ depfile='$(DEPDIR)/strutil.Plo' tmpdepfile='$(DEPDIR)/strutil.TPlo' @AMDEPBACKSLASH@ |
|
315 |
+@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
|
316 |
+ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o strutil.lo `test -f '$(top_srcdir)/shared/strutil.c' || echo '$(srcdir)/'`$(top_srcdir)/shared/strutil.c |
|
299 | 317 |
CCDEPMODE = @CCDEPMODE@ |
300 | 318 |
|
301 | 319 |
mostlyclean-libtool: |
... | ... |
@@ -33,6 +33,7 @@ |
33 | 33 |
|
34 | 34 |
#include "options.h" |
35 | 35 |
#include "others.h" |
36 |
+#include "strutil.h" |
|
36 | 37 |
|
37 | 38 |
void sigtool(struct optstruct *opt); |
38 | 39 |
|
... | ... |
@@ -113,9 +114,9 @@ int main(int argc, char **argv) |
113 | 113 |
opt->filename=(char*)mcalloc(len + 256, sizeof(char)); |
114 | 114 |
|
115 | 115 |
for(i=optind; i<argc; i++) { |
116 |
- strncat(opt->filename, argv[i], strlen(argv[i])); |
|
116 |
+ strlcat(opt->filename, argv[i], len+256); |
|
117 | 117 |
if(i != argc-1) |
118 |
- strncat(opt->filename, " ", 1); |
|
118 |
+ strlcat(opt->filename, " ", len+256); |
|
119 | 119 |
} |
120 | 120 |
|
121 | 121 |
} else |
... | ... |
@@ -47,6 +47,7 @@ |
47 | 47 |
#include "str.h" |
48 | 48 |
#include "memory.h" |
49 | 49 |
#include "output.h" |
50 |
+#include "strutil.h" |
|
50 | 51 |
|
51 | 52 |
#define LINE 1024 |
52 | 53 |
|
... | ... |
@@ -481,7 +482,7 @@ int build(struct optstruct *opt) |
481 | 481 |
{ |
482 | 482 |
int ret, no = 0, realno = 0, bytes, itmp; |
483 | 483 |
struct stat foo; |
484 |
- char buffer[FILEBUFF], *tarfile = NULL, *gzfile = NULL, header[257], |
|
484 |
+ char buffer[FILEBUFF], *tarfile = NULL, *gzfile = NULL, header[513], |
|
485 | 485 |
smbuff[30], *pt; |
486 | 486 |
struct cl_node *root = NULL; |
487 | 487 |
FILE *tar, *cvd, *fd; |
... | ... |
@@ -583,7 +584,7 @@ int build(struct optstruct *opt) |
583 | 583 |
|
584 | 584 |
/* magic string */ |
585 | 585 |
|
586 |
- strcpy(header, "ClamAV-VDB:"); |
|
586 |
+ strlcpy(header, "ClamAV-VDB:", sizeof(header)); |
|
587 | 587 |
|
588 | 588 |
/* time */ |
589 | 589 |
|
... | ... |
@@ -591,7 +592,7 @@ int build(struct optstruct *opt) |
591 | 591 |
brokent = localtime(&timet); |
592 | 592 |
setlocale(LC_TIME, "C"); |
593 | 593 |
strftime(smbuff, 30, "%d %b %Y %H-%M %z", brokent); |
594 |
- strcat(header, smbuff); |
|
594 |
+ strlcat(header, smbuff, sizeof(header)); |
|
595 | 595 |
|
596 | 596 |
/* version number */ |
597 | 597 |
|
... | ... |
@@ -605,21 +606,21 @@ int build(struct optstruct *opt) |
605 | 605 |
scanf("%d", &itmp); |
606 | 606 |
sprintf(smbuff, "%d:", itmp); |
607 | 607 |
} |
608 |
- strcat(header, smbuff); |
|
608 |
+ strlcat(header, smbuff, sizeof(header)); |
|
609 | 609 |
|
610 | 610 |
/* number of signatures */ |
611 | 611 |
sprintf(smbuff, "%d:", no); |
612 |
- strcat(header, smbuff); |
|
612 |
+ strlcat(header, smbuff, sizeof(header)); |
|
613 | 613 |
|
614 | 614 |
/* functionality level (TODO: use cl_funclevel()) */ |
615 | 615 |
sprintf(smbuff, "%d:", 1); |
616 |
- strcat(header, smbuff); |
|
616 |
+ strlcat(header, smbuff, sizeof(header)); |
|
617 | 617 |
|
618 | 618 |
/* MD5 */ |
619 | 619 |
pt = cl_md5file(gzfile); |
620 |
- strcat(header, pt); |
|
620 |
+ strlcat(header, pt, sizeof(header)); |
|
621 | 621 |
free(pt); |
622 |
- strcat(header, ":"); |
|
622 |
+ strlcat(header, ":", sizeof(header)); |
|
623 | 623 |
|
624 | 624 |
/* builder - question */ |
625 | 625 |
fflush(stdin); |
... | ... |
@@ -636,22 +637,17 @@ int build(struct optstruct *opt) |
636 | 636 |
exit(1); |
637 | 637 |
} |
638 | 638 |
|
639 |
- strcat(header, pt); |
|
639 |
+ strlcat(header, pt, sizeof(header)); |
|
640 | 640 |
free(pt); |
641 |
- strcat(header, ":"); |
|
641 |
+ strlcat(header, ":", sizeof(header)); |
|
642 | 642 |
|
643 | 643 |
/* builder - add */ |
644 |
- strcat(header, smbuff); |
|
644 |
+ strlcat(header, smbuff, sizeof(header)); |
|
645 | 645 |
|
646 | 646 |
/* fill up with spaces */ |
647 |
- if(strlen(header) > 512) { |
|
648 |
- mprintf("!Generated header is too long.\n"); |
|
649 |
- unlink(gzfile); |
|
650 |
- exit(1); |
|
651 |
- } |
|
652 | 647 |
|
653 | 648 |
while(strlen(header) < 512) |
654 |
- strcat(header, " "); |
|
649 |
+ strlcat(header, " ", sizeof(header)); |
|
655 | 650 |
|
656 | 651 |
/* build the final database */ |
657 | 652 |
|