Browse code

add lots of warnings flags to 'make distcheck', and turn some warnings into errors (bb #1092)

git-svn: trunk@4129

Török Edvin authored on 2008/08/22 05:21:43
Showing 34 changed files
... ...
@@ -28,6 +28,6 @@ pkgconfig_DATA = libclamav.pc
28 28
 # don't complain that configuration files and databases are not removed, this is intended
29 29
 distuninstallcheck_listfiles = find . -type f ! -name clamd.conf ! -name freshclam.conf ! -name daily.cvd ! -name main.cvd -print
30 30
 DISTCLEANFILES = target.h
31
-
31
+DISTCHECK_CONFIGURE_FLAGS=--enable-milter CFLAGS="-Wno-pointer-sign -Wno-error=attributes -Werror-implicit-function-declaration -Werror -Wextra -Wall -Wbad-function-cast -Wcast-align -Wendif-labels -Wfloat-equal -Wformat=2 -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wstrict-prototypes -Wno-error=strict-prototypes -Wno-switch -Wundef -Wwrite-strings -Wstrict-overflow=1 -Winit-self -Wmissing-include-dirs -Wstrict-aliasing -Wdeclaration-after-statement -Waggregate-return -Wmissing-format-attribute -Wpadded -Wno-error=type-limits -Wno-error=unused-value -Wno-error=unused-variable -Wcast-qual -Wno-error=cast-qual -Wno-error=sign-compare -Wshadow -Wno-error=shadow -Wno-error=uninitialized -fdiagnostics-show-option -Wno-error=unused-parameter -Wpacked -Wno-error=packed -Wno-error=unreachable-code -Winvalid-pch -Wno-error=invalid-pch -O2 -D_FORTIFY_SOURCE=2 -fstack-protector-all -Wstack-protector -Wno-error=padded"
32 32
 lcov:
33 33
 	($(MAKE); cd unit_tests; $(MAKE) lcov)
... ...
@@ -263,6 +263,7 @@ pkgconfig_DATA = libclamav.pc
263 263
 # don't complain that configuration files and databases are not removed, this is intended
264 264
 distuninstallcheck_listfiles = find . -type f ! -name clamd.conf ! -name freshclam.conf ! -name daily.cvd ! -name main.cvd -print
265 265
 DISTCLEANFILES = target.h
266
+DISTCHECK_CONFIGURE_FLAGS = --enable-milter CFLAGS="-Wno-pointer-sign -Wno-error=attributes -Werror-implicit-function-declaration -Werror -Wextra -Wall -Wbad-function-cast -Wcast-align -Wendif-labels -Wfloat-equal -Wformat=2 -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wstrict-prototypes -Wno-error=strict-prototypes -Wno-switch -Wundef -Wwrite-strings -Wstrict-overflow=1 -Winit-self -Wmissing-include-dirs -Wstrict-aliasing -Wdeclaration-after-statement -Waggregate-return -Wmissing-format-attribute -Wpadded -Wno-error=type-limits -Wno-error=unused-value -Wno-error=unused-variable -Wcast-qual -Wno-error=cast-qual -Wno-error=sign-compare -Wshadow -Wno-error=shadow -Wno-error=uninitialized -fdiagnostics-show-option -Wno-error=unused-parameter -Wpacked -Wno-error=packed -Wno-error=unreachable-code -Winvalid-pch -Wno-error=invalid-pch -O2 -D_FORTIFY_SOURCE=2 -fstack-protector-all -Wstack-protector -Wno-error=padded"
266 267
 all: clamav-config.h
267 268
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
268 269
 
... ...
@@ -790,7 +791,6 @@ uninstall-am: uninstall-binSCRIPTS uninstall-pkgconfigDATA
790 790
 	tags tags-recursive uninstall uninstall-am \
791 791
 	uninstall-binSCRIPTS uninstall-pkgconfigDATA
792 792
 
793
-
794 793
 lcov:
795 794
 	($(MAKE); cd unit_tests; $(MAKE) lcov)
796 795
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
... ...
@@ -54,7 +54,6 @@ size_t cli_strlcpy(char *dst, const char *src, size_t siz);
54 54
 int
55 55
 clamd_fdscan(int s, int fd, char *name, size_t len)
56 56
 {
57
-	struct sockaddr_un addr;
58 57
 	struct msghdr msg;
59 58
 	struct cmsghdr *cmsg;
60 59
 	unsigned char fdbuf[CMSG_SPACE(sizeof(int))];
... ...
@@ -62,8 +61,9 @@ clamd_fdscan(int s, int fd, char *name, size_t len)
62 62
 	char buf[CLAMD_BUFSIZ], *p, *q;
63 63
 	off_t pos;
64 64
 	struct iovec iov[1];
65
+	char dummy[]="";
65 66
 
66
-	iov[0].iov_base = "";
67
+	iov[0].iov_base = dummy;
67 68
 	iov[0].iov_len = 1;
68 69
 
69 70
 	pos = lseek(fd, 0, SEEK_CUR);
... ...
@@ -81,7 +81,11 @@ clamd_fdscan(int s, int fd, char *name, size_t len)
81 81
 	cmsg->cmsg_type = SCM_RIGHTS;
82 82
 	*(int *)CMSG_DATA(cmsg) = fd;
83 83
 
84
-	write(s, "FILDES\n", sizeof("FILDES\n")-1);
84
+	if(write(s, "FILDES\n", sizeof("FILDES\n")-1) != sizeof("FILDES\n")-1) {
85
+		perror("write");
86
+		close(s);
87
+		return -1;
88
+	}
85 89
 	if (sendmsg(s, &msg, 0) == -1) {
86 90
 		perror("sendmsg");
87 91
 		close(s);
... ...
@@ -89,7 +93,11 @@ clamd_fdscan(int s, int fd, char *name, size_t len)
89 89
 	}
90 90
 
91 91
 	sp = fdopen(s,"r");
92
-	fgets(buf, sizeof(buf), sp);
92
+	if(!fgets(buf, sizeof(buf), sp)) {
93
+		fclose(sp);
94
+		close(s);
95
+		return -1;
96
+	}
93 97
 	fclose(sp);
94 98
 	close(s);
95 99
 
... ...
@@ -48,6 +48,7 @@
48 48
 #include "misc.h"
49 49
 #include "str.h"
50 50
 #include "client.h"
51
+#include "clamd_fdscan.h"
51 52
 
52 53
 #ifdef PF_INET
53 54
 # define SOCKET_INET	PF_INET
... ...
@@ -746,7 +746,9 @@ static void move_infected(const char *filename, const struct optstruct *opt)
746 746
 
747 747
 	chmod(movefilename, ofstat.st_mode);
748 748
 #ifndef C_OS2
749
-	chown(movefilename, ofstat.st_uid, ofstat.st_gid);
749
+	if(chown(movefilename, ofstat.st_uid, ofstat.st_gid) == -1) {
750
+		logg("!Can't chown '%s': %s\n", movefilename, strerror(errno));
751
+	}
750 752
 #endif
751 753
 
752 754
 	ubuf.actime = ofstat.st_atime;
... ...
@@ -11289,7 +11289,7 @@ cat >>conftest.$ac_ext <<_ACEOF
11289 11289
 /* (C) Richard Guenther */
11290 11290
 extern void abort(void);
11291 11291
 
11292
-int try (char *a, int d)
11292
+static int try (char *a, int d)
11293 11293
 {
11294 11294
   return a + d > a;
11295 11295
 }
... ...
@@ -11375,7 +11375,7 @@ extern void abort(void);
11375 11375
 
11376 11376
 int crashtest()
11377 11377
 {
11378
-	unsigned int backsize, dcur,i;
11378
+	unsigned int backsize, dcur;
11379 11379
 	int dval=0x12000, unp_offset;
11380 11380
 	int* dsize = &dval;
11381 11381
 	char* dst = (char*)0x12000;
... ...
@@ -11470,14 +11470,14 @@ struct a
11470 11470
    unsigned int bits : 1;
11471 11471
    signed long val : ((sizeof(long) * 8) - 1);
11472 11472
 };
11473
-int Fnegate (struct a b)
11473
+static int Fnegate (struct a b)
11474 11474
 {
11475 11475
   if ((-((long)b.val)) <= ((long) ((1UL << ((sizeof(long) * 8) - 2)) -1UL))
11476 11476
       && (-((long)b.val)) >= (-(((long) ((1UL << ((sizeof(long) * 8) - 2)) -1UL))) - 1))
11477 11477
      return 0 ;
11478 11478
   abort ();
11479 11479
 }
11480
-int main ()
11480
+int main (void)
11481 11481
 {
11482 11482
   struct a b = {1, 1};
11483 11483
   Fnegate (b);
... ...
@@ -133,7 +133,7 @@ AC_TRY_RUN(
133 133
 /* (C) Richard Guenther */	   
134 134
 extern void abort(void);
135 135
 
136
-int try (char *a, int d)
136
+static int try (char *a, int d)
137 137
 {
138 138
   return a + d > a;
139 139
 }
... ...
@@ -174,7 +174,7 @@ extern void abort(void);
174 174
 
175 175
 int crashtest()
176 176
 {
177
-	unsigned int backsize, dcur,i;
177
+	unsigned int backsize, dcur;
178 178
 	int dval=0x12000, unp_offset;
179 179
 	int* dsize = &dval;
180 180
 	char* dst = (char*)0x12000;
... ...
@@ -225,14 +225,14 @@ struct a
225 225
    unsigned int bits : 1;
226 226
    signed long val : ((sizeof(long) * 8) - 1);
227 227
 };
228
-int Fnegate (struct a b)
228
+static int Fnegate (struct a b)
229 229
 {
230 230
   if ((-((long)b.val)) <= ((long) ((1UL << ((sizeof(long) * 8) - 2)) -1UL))
231 231
       && (-((long)b.val)) >= (-(((long) ((1UL << ((sizeof(long) * 8) - 2)) -1UL))) - 1))
232 232
      return 0 ;
233 233
   abort ();
234 234
 }
235
-int main ()
235
+int main (void)
236 236
 {
237 237
   struct a b = {1, 1};
238 238
   Fnegate (b);
... ...
@@ -32,5 +32,6 @@ echo "Downloading updated country-code list from iana.org"
32 32
 wget $IANA_CCTLD -O $TMP || exit 2
33 33
 echo "Download complete, parsing data"
34 34
 cat $TMP | grep country-code|egrep -oi "<a
35
-href=[^>]+>\\.([a-zA-Z]+).+</a>"|egrep -o ">.[a-zA-Z]+" | colrm 1 2 | tr [A-Z] [a-z]| gperf -C -l -L ANSI-C -E -C -H cctld_hash -N in_cctld_set |grep -v '^#line'|sed -e 's/^const struct/static const struct/' -e 's/register //g' >iana_cctld.h
35
+href=[^>]+>\\.([a-zA-Z]+).+</a>"|egrep -o ">.[a-zA-Z]+" | colrm 1 2 | tr [A-Z]
36
+[a-z]| gperf -C -l -L ANSI-C -E -C -H cctld_hash -N in_cctld_set |grep -v '^#line'|sed -e 's/^const struct/static const struct/' -e 's/register //g' -e 's/^const char \*/static const char */' >iana_cctld.h
36 37
 echo "Done"
... ...
@@ -26,6 +26,7 @@
26 26
 
27 27
 #include <stdio.h>
28 28
 
29
+#include "dns.h"
29 30
 #ifdef HAVE_RESOLV_H
30 31
 
31 32
 #include <string.h>
... ...
@@ -37,7 +38,6 @@
37 37
 
38 38
 #include "shared/output.h"
39 39
 
40
-#include "dns.h"
41 40
 
42 41
 #ifndef PACKETSZ
43 42
 #define PACKETSZ 512
... ...
@@ -41,6 +41,7 @@
41 41
 
42 42
 #include "others.h"
43 43
 #include "scanners.h"
44
+#include "autoit.h"
44 45
 
45 46
 
46 47
 /* FIXME: use unicode detection and normalization from edwin */
... ...
@@ -348,17 +348,6 @@ const struct element* hashtab_insert(struct hashtable *s, const char* key, const
348 348
 	return NULL;
349 349
 }
350 350
 
351
-void hashtab_delete(struct hashtable *s, const char* key, const size_t len)
352
-{
353
-	struct element* e = hashtab_find(s,key,len);
354
-	if(e && e->key) {
355
-		PROFILE_HASH_DELETE(s);
356
-		free((void *)e->key);
357
-		e->key = DELETED_KEY;
358
-		s->used--;
359
-	}
360
-}
361
-
362 351
 void hashtab_clear(struct hashtable *s)
363 352
 {
364 353
 	size_t i;
... ...
@@ -302,7 +302,7 @@ static inline void html_output_c(file_buff_t *fbuff1, unsigned char c)
302 302
 	}
303 303
 }
304 304
 
305
-static void html_output_str(file_buff_t *fbuff, const unsigned char *str, int len)
305
+static void html_output_str(file_buff_t *fbuff, const unsigned char *str, size_t len)
306 306
 {
307 307
 	if (fbuff) {
308 308
 		if ((fbuff->length + len) >= HTML_FILE_BUFF_LEN) {
... ...
@@ -561,7 +561,7 @@ static void screnc_decode(unsigned char *ptr, struct screnc_state *s)
561 561
 			expected += (base64_chars[ptr[5]] >> 4) << 24;
562 562
 			ptr += 8;
563 563
 			if(s->sum != expected) {
564
-				cli_dbgmsg("screnc_decode: checksum mismatch: %lu != %lu\n", s->sum, expected);
564
+				cli_dbgmsg("screnc_decode: checksum mismatch: %u != %u\n", s->sum, expected);
565 565
 			} else {
566 566
 				if(strncmp(ptr, "^#~@", 4) != 0) {
567 567
 					cli_dbgmsg("screnc_decode: terminator not found\n");
... ...
@@ -1787,14 +1787,14 @@ int html_screnc_decode(int fd, const char *dirname)
1787 1787
 
1788 1788
 	while (screnc_state.length && line) {
1789 1789
 		screnc_decode(ptr, &screnc_state);
1790
-		write(ofd, ptr, strlen(ptr));
1790
+		cli_writen(ofd, ptr, strlen(ptr));
1791 1791
 		free(line);
1792 1792
 		if (screnc_state.length) {
1793 1793
 			ptr = line = cli_readchunk(stream_in, NULL, 8192);
1794 1794
 		}
1795 1795
 	}
1796 1796
 	if(screnc_state.length)
1797
-		cli_dbgmsg("html_screnc_decode: missing %lu bytes\n",screnc_state.length);
1797
+		cli_dbgmsg("html_screnc_decode: missing %u bytes\n",screnc_state.length);
1798 1798
 	retval = TRUE;
1799 1799
 
1800 1800
 abort:
... ...
@@ -82,7 +82,7 @@ __inline
82 82
 __attribute__ ((__gnu_inline__))
83 83
 #endif
84 84
 #endif
85
-const char *
85
+static const char *
86 86
 in_cctld_set (const char *str, unsigned int len)
87 87
 {
88 88
   enum
... ...
@@ -99,7 +99,7 @@ __inline
99 99
 __attribute__ ((__gnu_inline__))
100 100
 #endif
101 101
 #endif
102
-const char *
102
+static const char *
103 103
 in_tld_set (const char *str, unsigned int len)
104 104
 {
105 105
   enum
... ...
@@ -3293,7 +3293,7 @@ strstrip(char *s)
3293 3293
 	if(s == (char *)NULL)
3294 3294
 		return(0);
3295 3295
 
3296
-	return(strip(s, (int)strlen(s) + 1));
3296
+	return(strip(s, strlen(s) + 1));
3297 3297
 }
3298 3298
 
3299 3299
 /*
... ...
@@ -1433,7 +1433,7 @@ int lzx_decompress(struct lzx_stream *lzx, off_t out_bytes) {
1433 1433
 
1434 1434
     /* check that we've used all of the previous frame first */
1435 1435
     if (lzx->o_ptr != lzx->o_end) {
1436
-      cli_dbgmsg("lzx_decompress: %d avail bytes, new %d frame\n", lzx->o_end-lzx->o_ptr, frame_size);
1436
+      cli_dbgmsg("lzx_decompress: %ld avail bytes, new %d frame\n", lzx->o_end-lzx->o_ptr, frame_size);
1437 1437
       return lzx->error = CL_EFORMAT;
1438 1438
     }
1439 1439
 
... ...
@@ -65,7 +65,8 @@ static	char	const	rcsid[] = "$Id: pdf.c,v 1.61 2007/02/12 20:46:09 njh Exp $";
65 65
 #endif
66 66
 
67 67
 #ifdef	CL_DEBUG
68
-/*#define	SAVE_TMP	/* Save the file being worked on in tmp */
68
+/*#define	SAVE_TMP	
69
+ *Save the file being worked on in tmp */
69 70
 #endif
70 71
 
71 72
 static	int	try_flatedecode(unsigned char *buf, off_t real_len, off_t calculated_len, int fout, cli_ctx *ctx);
... ...
@@ -214,7 +214,7 @@ int petite_inflate2x_1to9(char *buf, uint32_t minrva, uint32_t bufsz, struct cli
214 214
       /* Let's compact data */
215 215
       for (t = 0; t < j ; t++) {
216 216
 	usects[t].raw = (t>0)?(usects[t-1].raw + usects[t-1].rsz):0;
217
-	if (usects[t].rsz != 0)
217
+	if (usects[t].rsz != 0) {
218 218
 	  if(CLI_ISCONTAINED(buf, bufsz, buf + usects[t].raw, usects[t].rsz)) {
219 219
 	    memmove(buf + usects[t].raw, adjbuf + usects[t].rva, usects[t].rsz);
220 220
 	  } else {
... ...
@@ -222,6 +222,7 @@ int petite_inflate2x_1to9(char *buf, uint32_t minrva, uint32_t bufsz, struct cli
222 222
 	    usects[t].raw = t>0 ? usects[t-1].raw : 0;
223 223
 	    usects[t].rsz = 0;
224 224
 	  }
225
+	}
225 226
       }
226 227
 
227 228
       /* Showtime!!! */
... ...
@@ -843,22 +843,6 @@ int phishingScan(message* m,const char* dir,cli_ctx* ctx,tag_arguments_t* hrefs)
843 843
 	return CL_CLEAN;
844 844
 }
845 845
 
846
-static char* str_compose(const char* a,const char* b,const char* c)
847
-{
848
-	const size_t a_len = strlen(a);
849
-	const size_t b_len = strlen(b);
850
-	const size_t c_len = strlen(c);
851
-	const size_t r_len = a_len+b_len+c_len+1;
852
-	char* concated = cli_malloc(r_len);
853
-	if(!concated)
854
-		return NULL;
855
-	strncpy(concated,a,a_len);
856
-	strncpy(concated+a_len,b,b_len);
857
-	strncpy(concated+a_len+b_len,c,c_len);
858
-	concated[r_len-1]='\0';
859
-	return concated;
860
-}
861
-
862 846
 static char hex2int(const unsigned char* src)
863 847
 {
864 848
 	return (src[0] == '0' && src[1] == '0') ? 
... ...
@@ -662,6 +662,7 @@ backref(struct match *m, char *start, char *stop, sopno startst, sopno stopst,
662 662
 	/* "can't happen" */
663 663
 	assert(nope);
664 664
 	/* NOTREACHED */
665
+	return(NULL);
665 666
 }
666 667
 
667 668
 /*
... ...
@@ -355,7 +355,7 @@ int init_regex_list(struct regex_matcher* matcher)
355 355
 	if((rc = cli_ac_init(&matcher->suffixes, 2, 32))) {
356 356
 		return rc;
357 357
 	}
358
-	if(rc = cli_bm_init(&matcher->md5_hashes)) {
358
+	if((rc = cli_bm_init(&matcher->md5_hashes))) {
359 359
 		return rc;
360 360
 	}
361 361
 	SO_init(&matcher->filter);
... ...
@@ -423,7 +423,7 @@ static int add_hash(struct regex_matcher *matcher, char* pattern, const char fl)
423 423
 	}
424 424
 	*pat->virname = fl;
425 425
 	SO_preprocess_add(&matcher->md5_filter, pat->pattern, pat->length);
426
-	if(rc = cli_bm_addpatt(&matcher->md5_hashes, pat)) {
426
+	if((rc = cli_bm_addpatt(&matcher->md5_hashes, pat))) {
427 427
 		cli_errmsg("add_hash: failed to add BM pattern\n");
428 428
 		free(pat->pattern);
429 429
 		free(pat->virname);
... ...
@@ -41,6 +41,7 @@
41 41
 #include "others.h"
42 42
 #include "clamav.h"
43 43
 #include "scanners.h"
44
+#include "sis.h"
44 45
 
45 46
 #define EC32(x) le32_to_host(x)
46 47
 #define EC16(x) le16_to_host(x)
... ...
@@ -118,7 +118,7 @@ static char *checkpe(char *dst, uint32_t dsize, char *pehdr, uint32_t *valign, u
118 118
 
119 119
 static int pefromupx (char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint32_t ep, uint32_t upx0, uint32_t upx1, uint32_t *magic, uint32_t dend)
120 120
 {
121
-  char *imports, *sections, *pehdr=NULL, *newbuf;
121
+  char *imports, *sections=NULL, *pehdr=NULL, *newbuf;
122 122
   unsigned int sectcnt=0, upd=1;
123 123
   uint32_t realstuffsz=0, valign=0;
124 124
   uint32_t foffset=0xd0+0xf8;
... ...
@@ -134,10 +134,10 @@ static int pefromupx (char *src, uint32_t ssize, char *dst, uint32_t *dsize, uin
134 134
   }
135 135
 
136 136
   if (!valign && ep - upx1 + 0x80 < ssize-8) {
137
-    char *pt = &src[ep - upx1 + 0x80];
137
+    const char *pt = &src[ep - upx1 + 0x80];
138 138
     cli_dbgmsg("UPX: bad magic - scanning for imports\n");
139 139
     
140
-    while ((pt=(char *)cli_memstr(pt, ssize - (pt-src) - 8, "\x8d\xbe", 2))) {
140
+    while ((pt=cli_memstr(pt, ssize - (pt-src) - 8, "\x8d\xbe", 2))) {
141 141
       if (pt[6] == '\x8b' && pt[7] == '\x07') { /* lea edi, [esi+imports] / mov eax, [edi] */
142 142
 	valign=pt-src+2-ep+upx1;
143 143
 	break;
... ...
@@ -25,6 +25,7 @@
25 25
 #include "cltypes.h"
26 26
 #include "others.h"
27 27
 #include "execs.h"
28
+#include "wwunpack.h"
28 29
 
29 30
 #if HAVE_STRING_H
30 31
 #include <string.h>
... ...
@@ -41,84 +41,6 @@
41 41
 static void rar_dbgmsg(const char* fmt,...){}
42 42
 #endif
43 43
 
44
-static void dump_tables(unpack_data_t *unpack_data)
45
-{
46
-	int i;
47
-	
48
-	/* Dump LD table */
49
-	rar_dbgmsg("LD Table MaxNum=%d\n", unpack_data->LD.MaxNum);
50
-	rar_dbgmsg("\tDecodeLen:");
51
-	for (i=0 ; i < 16; i++) {
52
-		rar_dbgmsg(" %.8d", unpack_data->LD.DecodeLen[i]);
53
-	}
54
-	rar_dbgmsg("\n\tDecodePos:");
55
-	for (i=0 ; i < 16; i++) {
56
-		rar_dbgmsg(" %.8d", unpack_data->LD.DecodePos[i]);
57
-	}
58
-	rar_dbgmsg("\n\tDecodeNum:");
59
-	for (i=0 ; i < NC; i++) {
60
-		rar_dbgmsg(" %.8d", unpack_data->LD.DecodeNum[i]);
61
-	}
62
-	
63
-	
64
-	rar_dbgmsg("\nDD Table MaxNum=%d\n", unpack_data->DD.MaxNum);
65
-	rar_dbgmsg("\tDecodeLen:");
66
-	for (i=0 ; i < 16; i++) {
67
-		rar_dbgmsg(" %.8d", unpack_data->DD.DecodeLen[i]);
68
-	}
69
-	rar_dbgmsg("\n\tDecodePos:");
70
-	for (i=0 ; i < 16; i++) {
71
-		rar_dbgmsg(" %.8d", unpack_data->DD.DecodePos[i]);
72
-	}
73
-	rar_dbgmsg("\n\tDecodeNum:");
74
-	for (i=0 ; i < DC; i++) {
75
-		rar_dbgmsg(" %.8d", unpack_data->DD.DecodeNum[i]);
76
-	}
77
-	
78
-	rar_dbgmsg("\nLDD Table MaxNum=%d\n", unpack_data->LDD.MaxNum);
79
-	rar_dbgmsg("\tDecodeLen:");
80
-	for (i=0 ; i < 16; i++) {
81
-		rar_dbgmsg(" %.8d", unpack_data->LDD.DecodeLen[i]);
82
-	}
83
-	rar_dbgmsg("\n\tDecodePos:");
84
-	for (i=0 ; i < 16; i++) {
85
-		rar_dbgmsg(" %.8d", unpack_data->LDD.DecodePos[i]);
86
-	}
87
-	rar_dbgmsg("\n\tDecodeNum:");
88
-	for (i=0 ; i < LDC; i++) {
89
-		rar_dbgmsg(" %.8d", unpack_data->LDD.DecodeNum[i]);
90
-	}
91
-	
92
-	rar_dbgmsg("\nRD Table MaxNum=%d\n", unpack_data->RD.MaxNum);
93
-	rar_dbgmsg("\tDecodeLen:");
94
-	for (i=0 ; i < 16; i++) {
95
-		rar_dbgmsg(" %.8d", unpack_data->RD.DecodeLen[i]);
96
-	}
97
-	rar_dbgmsg("\n\tDecodePos:");
98
-	for (i=0 ; i < 16; i++) {
99
-		rar_dbgmsg(" %.8d", unpack_data->RD.DecodePos[i]);
100
-	}
101
-	rar_dbgmsg("\n\tDecodeNum:");
102
-	for (i=0 ; i < RC; i++) {
103
-		rar_dbgmsg(" %.8d", unpack_data->RD.DecodeNum[i]);
104
-	}
105
-	
106
-	rar_dbgmsg("\nBD Table MaxNum=%d\n", unpack_data->BD.MaxNum);
107
-	rar_dbgmsg("\tDecodeLen:");
108
-	for (i=0 ; i < 16; i++) {
109
-		rar_dbgmsg(" %.8d", unpack_data->BD.DecodeLen[i]);
110
-	}
111
-	rar_dbgmsg("\n\tDecodePos:");
112
-	for (i=0 ; i < 16; i++) {
113
-		rar_dbgmsg(" %.8d", unpack_data->BD.DecodePos[i]);
114
-	}
115
-	rar_dbgmsg("\n\tDecodeNum:");
116
-	for (i=0 ; i < BC; i++) {
117
-		rar_dbgmsg(" %.8d", unpack_data->BD.DecodeNum[i]);
118
-	}
119
-	rar_dbgmsg("\n");
120
-}
121
-
122 44
 static void insert_old_dist(unpack_data_t *unpack_data, unsigned int distance)
123 45
 {
124 46
 	unpack_data->old_dist[3] = unpack_data->old_dist[2];
... ...
@@ -230,8 +152,7 @@ unsigned int rar_get_char(int fd, unpack_data_t *unpack_data)
230 230
 static void unp_write_data(unpack_data_t *unpack_data, uint8_t *data, int size)
231 231
 {
232 232
 	rar_dbgmsg("in unp_write_data length=%d\n", size);
233
-	write(unpack_data->ofd, data, size);
234
-	unpack_data->written_size += size;
233
+	unpack_data->written_size += write(unpack_data->ofd, data, size);
235 234
 	unpack_data->unp_crc = rar_crc(unpack_data->unp_crc, data, size);
236 235
 }
237 236
 
... ...
@@ -23,7 +23,7 @@ void *rar_malloc(size_t size)
23 23
 
24 24
 
25 25
     if(!size || size > RAR_MAX_ALLOCATION) {
26
-	fprintf(stderr, "UNRAR: rar_malloc(): Attempt to allocate %u bytes. Please report to http://bugs.clamav.net\n", size);
26
+	fprintf(stderr, "UNRAR: rar_malloc(): Attempt to allocate %lu bytes. Please report to http://bugs.clamav.net\n", size);
27 27
 	return NULL;
28 28
     }
29 29
 
... ...
@@ -34,7 +34,7 @@ void *rar_malloc(size_t size)
34 34
 #endif
35 35
 
36 36
     if(!alloc) {
37
-	fprintf(stderr, "UNRAR: rar_malloc(): Can't allocate memory (%u bytes).\n", size);
37
+	fprintf(stderr, "UNRAR: rar_malloc(): Can't allocate memory (%lu bytes).\n", size);
38 38
 	perror("malloc_problem");
39 39
 	return NULL;
40 40
     } else return alloc;
... ...
@@ -46,14 +46,14 @@ void *rar_realloc2(void *ptr, size_t size)
46 46
 
47 47
 
48 48
     if(!size || size > RAR_MAX_ALLOCATION) {
49
-	fprintf(stderr, "UNRAR: rar_realloc2(): Attempt to allocate %u bytes. Please report to http://bugs.clamav.net\n", size);
49
+	fprintf(stderr, "UNRAR: rar_realloc2(): Attempt to allocate %lu bytes. Please report to http://bugs.clamav.net\n", size);
50 50
 	return NULL;
51 51
     }
52 52
 
53 53
     alloc = realloc(ptr, size);
54 54
 
55 55
     if(!alloc) {
56
-	fprintf(stderr, "UNRAR: rar_realloc2(): Can't allocate memory (%u bytes).\n", size);
56
+	fprintf(stderr, "UNRAR: rar_realloc2(): Can't allocate memory (%lu bytes).\n", size);
57 57
 	perror("rar_realloc2");
58 58
 	if(ptr)
59 59
 	    free(ptr);
... ...
@@ -87,20 +87,6 @@ static uint8_t vm_cmdflags[]=
87 87
 
88 88
 #define UINT32(x)  (sizeof(uint32_t)==4 ? (uint32_t)(x):((x)&0xffffffff))
89 89
 
90
-static unsigned int rarvm_get_value(int byte_mode, unsigned int *addr)
91
-{
92
-	if (byte_mode) {
93
-		return *addr;
94
-	} else {
95
-#if WORDS_BIGENDIAN == 0
96
-		return UINT32(*addr);
97
-#else
98
-                unsigned char *B = (unsigned char *)addr;
99
-                return UINT32((uint8_t)B[0]|((uint8_t)B[1]<<8)|((uint8_t)B[2]<<16)|((uint8_t)B[3]<<24));
100
-#endif
101
-	}
102
-}
103
-
104 90
 #if WORDS_BIGENDIAN == 0
105 91
 #define GET_VALUE(byte_mode,addr) ((byte_mode) ? (*(unsigned char *)(addr)) : UINT32((*(unsigned int *)(addr))))
106 92
 #else
... ...
@@ -172,7 +158,7 @@ uint32_t rar_crc(uint32_t start_crc, void *addr, uint32_t size)
172 172
 
173 173
 	data = addr;
174 174
 #if WORDS_BIGENDIAN == 0
175
-	while (size > 0 && ((int)data & 7))
175
+	while (size > 0 && ((long)data & 7))
176 176
 	{
177 177
 		start_crc = crc_tab[(unsigned char)(start_crc^data[0])]^(start_crc>>8);
178 178
 		size--;
... ...
@@ -945,7 +931,7 @@ int rarvm_execute(rarvm_data_t *rarvm_data, struct rarvm_prepared_program *prg)
945 945
 	return TRUE;
946 946
 }
947 947
 
948
-void rarvm_decode_arg(rarvm_data_t *rarvm_data, rarvm_input_t *rarvm_input,
948
+static void rarvm_decode_arg(rarvm_data_t *rarvm_data, rarvm_input_t *rarvm_input,
949 949
 		struct rarvm_prepared_operand *op, int byte_mode)
950 950
 {
951 951
 	uint16_t data;
... ...
@@ -986,7 +972,7 @@ void rarvm_decode_arg(rarvm_data_t *rarvm_data, rarvm_input_t *rarvm_input,
986 986
 	}
987 987
 }
988 988
 
989
-void rarvm_optimize(struct rarvm_prepared_program *prg)
989
+static void rarvm_optimize(struct rarvm_prepared_program *prg)
990 990
 {
991 991
 	struct rarvm_prepared_command *code, *cmd;
992 992
 	int code_size, i, flags_required, j, flags;
... ...
@@ -204,7 +204,7 @@ static unrar_fileheader_t *read_block(int fd, header_type hdr_type)
204 204
 static int is_rar_archive(int fd)
205 205
 {
206 206
 	mark_header_t mark;
207
-	const mark_header_t rar_hdr[2] = {{0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00}, {'U', 'n', 'i', 'q', 'u', 'E', '!'}};
207
+	const mark_header_t rar_hdr[2] = {{{0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00}}, {{'U', 'n', 'i', 'q', 'u', 'E', '!'}}};
208 208
 
209 209
 
210 210
     if(read(fd, &mark, SIZEOF_MARKHEAD) != SIZEOF_MARKHEAD)
... ...
@@ -39,4 +39,5 @@ int dircopy(const char *src, const char *dest);
39 39
 int cvd_unpack(const char *cvd, const char *destdir);
40 40
 int daemonize(void);
41 41
 const char *get_version(void);
42
+int match_regex(const char *filename, const char *pattern);
42 43
 #endif
... ...
@@ -26,7 +26,11 @@
26 26
 #include <stdlib.h>
27 27
 #include "cfgparser.h"
28 28
 
29
+#ifdef __GNUC__
30
+int mdprintf(int desc, const char *str, ...) __attribute__((format(printf, 2,3)));
31
+#else
29 32
 int mdprintf(int desc, const char *str, ...);
33
+#endif
30 34
 
31 35
 #ifdef __GNUC__
32 36
 int logg(const char *str, ...)      __attribute__((format(printf, 1, 2)));
... ...
@@ -350,7 +350,7 @@ static char *getdsig(const char *host, const char *user, const unsigned char *da
350 350
 	    close(sockd);
351 351
 	    return NULL;
352 352
 	} else {
353
-	    mprintf("Signature received (length = %u)\n", strlen(buff) - 10);
353
+	    mprintf("Signature received (length = %lu)\n", strlen(buff) - 10);
354 354
 	}
355 355
     } else {
356 356
 	mprintf("!getdsig: Communication error with remote server\n");
... ...
@@ -54,6 +54,7 @@ END_TEST
54 54
 
55 55
 /* extern void cl_debug(void); */
56 56
 START_TEST (test_cl_debug)
57
+{
57 58
     int old_status = cli_debug_flag;
58 59
     cli_debug_flag = 0;
59 60
     cl_debug();
... ...
@@ -63,6 +64,7 @@ START_TEST (test_cl_debug)
63 63
     cl_debug();
64 64
     fail_unless(1 == cli_debug_flag, "cl_debug failed when flag was already set");
65 65
     cli_debug_flag = old_status;
66
+}
66 67
 END_TEST
67 68
 
68 69
 /* extern const char *cl_retdbdir(void); */
... ...
@@ -76,10 +78,12 @@ END_TEST
76 76
 
77 77
 /* extern const char *cl_retver(void); */
78 78
 START_TEST (test_cl_retver)
79
+{
79 80
     const char *ver = cl_retver();
80 81
     fail_unless(!strcmp(REPO_VERSION, ver),"cl_retver");
81 82
     fail_unless(strcspn(ver,"012345789") < strlen(ver),
82 83
 		    "cl_retver must have a number");
84
+}
83 85
 END_TEST
84 86
 
85 87
 /* extern void cl_cvdfree(struct cl_cvd *cvd); */
... ...
@@ -339,7 +343,6 @@ int open_testfile(const char *name)
339 339
 int main(int argc, char **argv)
340 340
 {
341 341
     int nf;
342
-    cl_debug();
343 342
     Suite *s = test_cl_suite();
344 343
     SRunner *sr = srunner_create(s);
345 344
 #ifdef CHECK_HAVE_LOOPS
... ...
@@ -358,6 +361,7 @@ int main(int argc, char **argv)
358 358
     if(freopen("test-stderr.log","w+",stderr) == NULL) {
359 359
 	    fputs("Unable to redirect stderr!\n",stderr);
360 360
     }
361
+    cl_debug();
361 362
 
362 363
     srunner_run_all(sr, CK_NORMAL);
363 364
     nf = srunner_ntests_failed(sr);
... ...
@@ -135,7 +135,7 @@ START_TEST (test_token_ival)
135 135
 	fail_unless(TOKEN_GET(&tok, string) == NULL, "token ival->string");
136 136
 	fail_unless(TOKEN_GET(&tok, cstring) == NULL, "token ival->cstring");
137 137
 	fail_unless(TOKEN_GET(&tok, scope) == NULL, "token ival->scope");
138
-	fail_unless(TOKEN_GET(&tok, dval) == -1, "token ival->dval");
138
+	fail_unless(TOKEN_GET(&tok, dval) - -1 < 1e-9, "token ival->dval");
139 139
 	fail_unless(TOKEN_GET(&tok, ival) == val, "token ival->ival");
140 140
 }
141 141
 END_TEST
... ...
@@ -150,7 +150,7 @@ START_TEST (test_token_dval)
150 150
 	fail_unless(TOKEN_GET(&tok, string) == NULL, "token dval->string");
151 151
 	fail_unless(TOKEN_GET(&tok, cstring) == NULL, "token dval->cstring");
152 152
 	fail_unless(TOKEN_GET(&tok, scope) == NULL, "token dval->scope");
153
-	fail_unless(TOKEN_GET(&tok, dval) == val, "token dval->dval");
153
+	fail_unless(TOKEN_GET(&tok, dval) - val < 1e-9, "token dval->dval");
154 154
 	fail_unless(TOKEN_GET(&tok, ival) == -1, "token dval->ival");
155 155
 }
156 156
 END_TEST
... ...
@@ -25,6 +25,7 @@
25 25
 
26 26
 #include <check.h>
27 27
 #include <stdio.h>
28
+#include <string.h>
28 29
 
29 30
 #include "../libclamav/clamav.h"
30 31
 #include "../libclamav/readdb.h"