Browse code

fix compiler warnings, more to come (bb #273)

git-svn: trunk@4346

Török Edvin authored on 2008/11/06 23:27:43
Showing 17 changed files
... ...
@@ -1,3 +1,13 @@
1
+Thu Nov  6 15:24:34 EET 2008 (edwin)
2
+------------------------------------
3
+ * Makefile.am, clamd/session.c, clamd/thrmgr.c, libclamav/dlp.c,
4
+ libclamav/htmlnorm.c, libclamav/jsparse/js-norm.c,
5
+ libclamav/mpool.c, libclamav/mpool.h, libclamav/pe.c,
6
+ libclamav/phishcheck.c, libclamav/readdb.c, libclamav/upack.c,
7
+ libclamav/upx.c, libclamunrar/unrar.c, libclamunrar/unrarvm.c,
8
+ libclamunrar_iface/unrar_iface.c: fix compiler warnings, more to
9
+ come (bb #273)
10
+
1 11
 Thu Nov  6 12:29:26 EET 2008 (edwin)
2 12
 ------------------------------------
3 13
  * contrib/clamdtop/clamdtop.c: reconnect if connection is broken use
... ...
@@ -29,7 +29,7 @@ pkgconfig_DATA = libclamav.pc
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
 if DISTCHECK_ENABLE_FLAGS 
32
-DISTCHECK_CONFIGURE_FLAGS=--enable-milter --disable-clamav 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 -Wno-error=missing-prototypes -Wnested-externs -Wno-error=nested-externs -Wpointer-arith -Wstrict-prototypes -Wno-error=strict-prototypes -Wno-switch -Wno-switch-enum -Wundef -Wwrite-strings -Wstrict-overflow=1 -Winit-self -Wmissing-include-dirs -Wstrict-aliasing -Wdeclaration-after-statement -Waggregate-return -Wmissing-format-attribute -Wno-error=missing-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-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
+DISTCHECK_CONFIGURE_FLAGS=--enable-milter --disable-clamav 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 -Wno-error=missing-prototypes -Wnested-externs -Wno-error=nested-externs -Wpointer-arith -Wstrict-prototypes -Wno-error=strict-prototypes -Wno-switch -Wno-switch-enum -Wundef -Wwrite-strings -Wstrict-overflow=1 -Winit-self -Wmissing-include-dirs -Wstrict-aliasing -Wdeclaration-after-statement -Waggregate-return -Wmissing-format-attribute -Wno-error=missing-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-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 -Wno-error=aggregate-return"
33 33
 else
34 34
 DISTCHECK_CONFIGURE_FLAGS=--enable-milter --disable-clamav
35 35
 endif
... ...
@@ -65,6 +65,7 @@
65 65
 #include "scanner.h"
66 66
 #include "server.h"
67 67
 #include "session.h"
68
+#include "thrmgr.h"
68 69
 
69 70
 #ifdef HAVE_FD_PASSING
70 71
 static int recvfd_and_scan(int desc, const struct cl_engine *engine, const struct cl_limits *limits, unsigned int options, const struct cfgstruct *copt)
... ...
@@ -155,8 +155,8 @@ static void remove_frompools(threadpool_t *t)
155 155
 int thrmgr_printstats(int f)
156 156
 {
157 157
 	struct threadpool_list *l;
158
-	size_t cnt;
159
-	size_t pool_used = 0, pool_total = 0, pool_cnt = 0, seen_cnt = 0, error_flag = 0;
158
+	unsigned cnt, pool_cnt = 0;
159
+	size_t pool_used = 0, pool_total = 0, seen_cnt = 0, error_flag = 0;
160 160
 	float mem_heap = 0, mem_mmap = 0, mem_used = 0, mem_free = 0, mem_releasable = 0;
161 161
 	const struct cl_engine **seen = NULL;
162 162
 
... ...
@@ -169,7 +169,7 @@ int thrmgr_printstats(int f)
169 169
 		work_item_t *q;
170 170
 		struct timeval tv_now;
171 171
 		unsigned long umin=~0UL, umax=0, usum=0;
172
-		size_t invalids=0, cnt=0;
172
+		unsigned invalids=0, cnt=0;
173 173
 		struct task_desc *task;
174 174
 
175 175
 		if(!pool) {
... ...
@@ -190,6 +190,9 @@ int thrmgr_printstats(int f)
190 190
 			case POOL_EXIT:
191 191
 				state = "EXIT";
192 192
 				break;
193
+			default:
194
+				state = "??";
195
+				break;
193 196
 		}
194 197
 		mdprintf(f, "STATE: %s %s\n", state, l->nxt ? "" : "PRIMARY");
195 198
 		mdprintf(f, "THREADS: live %u  idle %u max %u idle-timeout %u\n"
... ...
@@ -220,7 +223,7 @@ int thrmgr_printstats(int f)
220 220
 		}
221 221
 		if(cnt + invalids != pool->queue->item_count)
222 222
 			mdprintf(f," (ERROR: %u != %u)", cnt + invalids,
223
-					pool->queue->item_count);
223
+					(unsigned)pool->queue->item_count);
224 224
 		mdprintf(f, "\n");
225 225
 		for(task = pool->tasks; task; task = task->nxt) {
226 226
 			long delta;
... ...
@@ -298,7 +298,7 @@ int dlp_is_valid_ssn(const unsigned char *buffer, int length, int format)
298 298
     if((length > minlength) && isdigit(buffer[minlength]))
299 299
 	return 0;
300 300
         
301
-    strncpy(numbuf, buffer, minlength);
301
+    strncpy(numbuf, (const char*)buffer, minlength);
302 302
     numbuf[minlength] = 0;
303 303
 
304 304
     /* sscanf parses and (basically) validates the string for us */
... ...
@@ -326,8 +326,8 @@ static char *html_tag_arg_value(tag_arguments_t *tags, const char *tag)
326 326
 	int i;
327 327
 	
328 328
 	for (i=0; i < tags->count; i++) {
329
-		if (strcmp(tags->tag[i], tag) == 0) {
330
-			return tags->value[i];
329
+		if (strcmp((const char*)tags->tag[i], tag) == 0) {
330
+			return (char*)tags->value[i];
331 331
 		}
332 332
 	}
333 333
 	return NULL;
... ...
@@ -338,16 +338,16 @@ static void html_tag_arg_set(tag_arguments_t *tags, const char *tag, const char
338 338
 	int i;
339 339
 	
340 340
 	for (i=0; i < tags->count; i++) {
341
-		if (strcmp(tags->tag[i], tag) == 0) {
341
+		if (strcmp((const char*)tags->tag[i], tag) == 0) {
342 342
 			free(tags->value[i]);
343
-			tags->value[i] = cli_strdup(value);
343
+			tags->value[i] = (unsigned char*)cli_strdup(value);
344 344
 			return;
345 345
 		}
346 346
 	}
347 347
 	return;
348 348
 }
349 349
 static void html_tag_arg_add(tag_arguments_t *tags,
350
-		const unsigned char *tag, unsigned char *value)
350
+		const char *tag, char *value)
351 351
 {
352 352
 	int len, i;
353 353
 	tags->count++;
... ...
@@ -369,16 +369,16 @@ static void html_tag_arg_add(tag_arguments_t *tags,
369 369
 		}
370 370
 		tags->contents[tags->count-1]=NULL;
371 371
 	}
372
-	tags->tag[tags->count-1] = cli_strdup(tag);
372
+	tags->tag[tags->count-1] = (unsigned char*)cli_strdup(tag);
373 373
 	if (value) {
374 374
 		if (*value == '"') {
375
-			tags->value[tags->count-1] = cli_strdup(value+1);
376
-			len = strlen(value+1);
375
+			tags->value[tags->count-1] = (unsigned char*)cli_strdup(value+1);
376
+			len = strlen((const char*)value+1);
377 377
 			if (len > 0) {
378 378
 				tags->value[tags->count-1][len-1] = '\0';
379 379
 			}
380 380
 		} else {
381
-			tags->value[tags->count-1] = cli_strdup(value);
381
+			tags->value[tags->count-1] = (unsigned char*)cli_strdup(value);
382 382
 		}
383 383
 	} else {
384 384
 		tags->value[tags->count-1] = NULL;
... ...
@@ -419,13 +419,13 @@ static void html_output_tag(file_buff_t *fbuff, char *tag, tag_arguments_t *tags
419 419
 	int i, j, len;
420 420
 
421 421
 	html_output_c(fbuff, '<');
422
-	html_output_str(fbuff, tag, strlen(tag));
422
+	html_output_str(fbuff, (const unsigned char*)tag, strlen(tag));
423 423
 	for (i=0; i < tags->count; i++) {
424 424
 		html_output_c(fbuff, ' ');
425
-		html_output_str(fbuff, tags->tag[i], strlen(tags->tag[i]));
425
+		html_output_str(fbuff, tags->tag[i], strlen((const char*)tags->tag[i]));
426 426
 		if (tags->value[i]) {
427
-			html_output_str(fbuff, "=\"", 2);
428
-			len = strlen(tags->value[i]);
427
+			html_output_str(fbuff, (const unsigned char*)"=\"", 2);
428
+			len = strlen((const char*)tags->value[i]);
429 429
 			for (j=0 ; j<len ; j++) {
430 430
 				html_output_c(fbuff, tolower(tags->value[i][j]));
431 431
 			}
... ...
@@ -548,7 +548,7 @@ static void screnc_decode(unsigned char *ptr, struct screnc_state *s)
548 548
 	}
549 549
 	if(!s->length) {
550 550
 		size_t remaining;
551
-		if(strlen(ptr) >= 12) {
551
+		if(strlen((const char*)ptr) >= 12) {
552 552
 			uint32_t expected;
553 553
 			expected = base64_chars[ptr[0]] << 2;
554 554
 			expected += base64_chars[ptr[1]] >> 4;
... ...
@@ -562,7 +562,7 @@ static void screnc_decode(unsigned char *ptr, struct screnc_state *s)
562 562
 			if(s->sum != expected) {
563 563
 				cli_dbgmsg("screnc_decode: checksum mismatch: %u != %u\n", s->sum, expected);
564 564
 			} else {
565
-				if(strncmp(ptr, "^#~@", 4) != 0) {
565
+				if(strncmp((const char*)ptr, "^#~@", 4) != 0) {
566 566
 					cli_dbgmsg("screnc_decode: terminator not found\n");
567 567
 				} else {
568 568
 					cli_dbgmsg("screnc_decode: OK\n");
... ...
@@ -571,15 +571,15 @@ static void screnc_decode(unsigned char *ptr, struct screnc_state *s)
571 571
 			ptr += 4;
572 572
 		}
573 573
 		/* copy remaining */
574
-		remaining = strlen(ptr) + 1;
574
+		remaining = strlen((const char*)ptr) + 1;
575 575
 		memmove(dst, ptr, remaining);
576 576
 	} else {
577 577
 		*dst = '\0';
578 578
 	}
579 579
 }
580 580
 
581
-static void js_process(struct parser_state *js_state, const char *js_begin, const char *js_end,
582
-		const char *line, const char *ptr, int in_script, const char *dirname)
581
+static void js_process(struct parser_state *js_state, const unsigned char *js_begin, const unsigned char *js_end,
582
+		const unsigned char *line, const unsigned char *ptr, int in_script, const char *dirname)
583 583
 {
584 584
 	if(!js_begin)
585 585
 		js_begin = line;
... ...
@@ -588,7 +588,7 @@ static void js_process(struct parser_state *js_state, const char *js_begin, cons
588 588
 	if(js_end > js_begin &&
589 589
 			CLI_ISCONTAINED(line, 8192, js_begin, 1) &&
590 590
 			CLI_ISCONTAINED(line, 8192, js_end, 1)) {
591
-		cli_js_process_buffer(js_state, js_begin, js_end - js_begin);
591
+		cli_js_process_buffer(js_state, (const char*)js_begin, js_end - js_begin);
592 592
 	}
593 593
 	if(!in_script) {
594 594
 		/*  we found a /script, normalize script now */
... ...
@@ -600,20 +600,20 @@ static void js_process(struct parser_state *js_state, const char *js_begin, cons
600 600
 
601 601
 static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag_arguments_t *hrefs,const struct cli_dconf* dconf)
602 602
 {
603
-	int fd_tmp, tag_length, tag_arg_length, binary;
604
-	int retval=FALSE, escape, value = 0, hex, tag_val_length=0;
603
+	int fd_tmp, tag_length = 0, tag_arg_length = 0, binary;
604
+	int retval=FALSE, escape=FALSE, value = 0, hex=FALSE, tag_val_length=0;
605 605
 	int look_for_screnc=FALSE, in_screnc=FALSE,in_script=FALSE, text_space_written=FALSE;
606 606
 	FILE *stream_in = NULL;
607 607
 	html_state state=HTML_NORM, next_state=HTML_BAD_STATE, saved_next_state=HTML_BAD_STATE;
608 608
 	char filename[1024], tag[HTML_STR_LENGTH+1], tag_arg[HTML_STR_LENGTH+1];
609
-	char tag_val[HTML_STR_LENGTH+1], *tmp_file;
610
-	unsigned char *line, *ptr, *arg_value, *ptr_screnc;
609
+	char tag_val[HTML_STR_LENGTH+1], *tmp_file, *arg_value;
610
+	unsigned char *line, *ptr, *ptr_screnc = NULL;
611 611
 	tag_arguments_t tag_args;
612
-	quoted_state quoted;
613
-	unsigned long length;
612
+	quoted_state quoted = NOT_QUOTED;
613
+	unsigned long length = 0;
614 614
 	struct screnc_state screnc_state;
615 615
 	file_buff_t *file_buff_o2, *file_buff_text;
616
-	file_buff_t *file_tmp_o1;
616
+	file_buff_t *file_tmp_o1 = NULL;
617 617
 	int in_ahref=0;/* index of <a> tag, whose contents we are parsing. Indexing starts from 1, 0 means outside of <a>*/
618 618
 	unsigned char* href_contents_begin=NULL;/*beginning of the next portion of <a> contents*/
619 619
 	unsigned char* ptrend=NULL;/*end of <a> contents*/
... ...
@@ -1067,13 +1067,13 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag
1067 1067
 				} else if (strcmp(tag, "script") == 0) {
1068 1068
 					arg_value = html_tag_arg_value(&tag_args, "language");
1069 1069
 					/* TODO: maybe we can output all tags only via html_output_tag */
1070
-					if (arg_value && (strcasecmp(arg_value, "jscript.encode") == 0)) {
1070
+					if (arg_value && (strcasecmp((const char*)arg_value, "jscript.encode") == 0)) {
1071 1071
 						html_tag_arg_set(&tag_args, "language", "javascript");
1072 1072
 						state = HTML_SKIP_WS;
1073 1073
 						next_state = HTML_JSDECODE;
1074 1074
 						/* we already output the old tag, output the new tag now */
1075 1075
 						html_output_tag(file_buff_o2, tag, &tag_args);
1076
-					} else if (arg_value && (strcasecmp(arg_value, "vbscript.encode") == 0)) {
1076
+					} else if (arg_value && (strcasecmp((const char*)arg_value, "vbscript.encode") == 0)) {
1077 1077
 						html_tag_arg_set(&tag_args, "language", "vbscript");
1078 1078
 						state = HTML_SKIP_WS;
1079 1079
 						next_state = HTML_JSDECODE;
... ...
@@ -1091,8 +1091,8 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag
1091 1091
 					}
1092 1092
 				} else if(strcmp(tag, "%@") == 0) {
1093 1093
 					arg_value = html_tag_arg_value(&tag_args, "language");
1094
-					if(arg_value && (strcasecmp(arg_value,"jscript.encode") == 0||
1095
-							strcasecmp(arg_value, "vbscript.encode") == 0)) {
1094
+					if(arg_value && (strcasecmp((const char*)arg_value,"jscript.encode") == 0||
1095
+							strcasecmp((const char*)arg_value, "vbscript.encode") == 0)) {
1096 1096
 
1097 1097
 						saved_next_state = next_state;
1098 1098
 						next_state = state;
... ...
@@ -1104,9 +1104,9 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag
1104 1104
 						href_contents_begin=ptr;
1105 1105
 					if (strcmp(tag, "a") == 0) {
1106 1106
 						arg_value = html_tag_arg_value(&tag_args, "href");
1107
-						if (arg_value && strlen(arg_value) > 0) {
1107
+						if (arg_value && strlen((const char*)arg_value) > 0) {
1108 1108
 							if (hrefs->scanContents) {
1109
-								unsigned char* arg_value_title = html_tag_arg_value(&tag_args,"title");
1109
+								char* arg_value_title = html_tag_arg_value(&tag_args,"title");
1110 1110
 								/*beginning of an <a> tag*/
1111 1111
 								if (in_ahref)
1112 1112
 									/*we encountered nested <a> tags, pretend previous closed*/
... ...
@@ -1119,8 +1119,8 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag
1119 1119
 								if (arg_value_title) {
1120 1120
 									/* title is a 'displayed link'*/
1121 1121
 									html_tag_arg_add(hrefs,"href_title",arg_value_title);
1122
-									html_tag_contents_append(&contents,arg_value,
1123
-										arg_value+strlen(arg_value));
1122
+									html_tag_contents_append(&contents,(const unsigned char*)arg_value,
1123
+										(const unsigned char*)arg_value+strlen(arg_value));
1124 1124
 									html_tag_contents_done(hrefs, hrefs->count, &contents);
1125 1125
 								}
1126 1126
 								if (in_form_action) {
... ...
@@ -1128,7 +1128,7 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag
1128 1128
 									html_tag_arg_add(hrefs,"form",arg_value);
1129 1129
 									contents.pos = 0;
1130 1130
 									html_tag_contents_append(&contents, in_form_action,
1131
-											in_form_action + strlen(in_form_action));
1131
+											in_form_action + strlen((const char*)in_form_action));
1132 1132
 									html_tag_contents_done(hrefs, hrefs->count, &contents);
1133 1133
 								}
1134 1134
 							}
... ...
@@ -1140,11 +1140,11 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag
1140 1140
 							}
1141 1141
 						}
1142 1142
 					} else if (strcmp(tag,"form") == 0 && hrefs->scanContents) {
1143
-						const unsigned char* arg_action_value = html_tag_arg_value(&tag_args,"action");
1143
+						const char* arg_action_value = html_tag_arg_value(&tag_args,"action");
1144 1144
 						if (arg_action_value) {
1145 1145
 							if(in_form_action)
1146 1146
 								free(in_form_action);
1147
-							in_form_action = cli_strdup(arg_action_value);
1147
+							in_form_action = (unsigned char*)cli_strdup(arg_action_value);
1148 1148
 						}
1149 1149
 					} else if (strcmp(tag, "img") == 0) {
1150 1150
 						arg_value = html_tag_arg_value(&tag_args, "src");
... ...
@@ -1152,13 +1152,13 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag
1152 1152
 							html_tag_arg_add(hrefs, "src", arg_value);
1153 1153
 							if(hrefs->scanContents && in_ahref)
1154 1154
 								/* "contents" of an img tag, is the URL of its parent <a> tag */
1155
-								hrefs->contents[hrefs->count-1] = cli_strdup(hrefs->value[in_ahref-1]);
1155
+								hrefs->contents[hrefs->count-1] = (unsigned char*)cli_strdup((const char*)hrefs->value[in_ahref-1]);
1156 1156
 							if (in_form_action) {
1157 1157
 								/* form action is the real URL, and href is the 'displayed' */
1158 1158
 								html_tag_arg_add(hrefs,"form",arg_value);
1159 1159
 								contents.pos = 0;
1160 1160
 								html_tag_contents_append(&contents, in_form_action,
1161
-										in_form_action + strlen(in_form_action));
1161
+										in_form_action + strlen((const char*)in_form_action));
1162 1162
 								html_tag_contents_done(hrefs, hrefs->count, &contents);
1163 1163
 							}
1164 1164
 						}
... ...
@@ -1167,13 +1167,13 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag
1167 1167
 							html_tag_arg_add(hrefs, "dynsrc", arg_value);
1168 1168
 							if(hrefs->scanContents && in_ahref)
1169 1169
 								/* see above */
1170
-								hrefs->contents[hrefs->count-1] = cli_strdup(hrefs->value[in_ahref-1]);
1170
+								hrefs->contents[hrefs->count-1] = (unsigned char*)cli_strdup((const char*)hrefs->value[in_ahref-1]);
1171 1171
 							if (in_form_action) {
1172 1172
 								/* form action is the real URL, and href is the 'displayed' */
1173 1173
 								html_tag_arg_add(hrefs,"form",arg_value);
1174 1174
 								contents.pos = 0;
1175 1175
 								html_tag_contents_append(&contents, in_form_action,
1176
-										in_form_action + strlen(in_form_action));
1176
+										in_form_action + strlen((const char*)in_form_action));
1177 1177
 								html_tag_contents_done(hrefs, hrefs->count, &contents);
1178 1178
 							}
1179 1179
 						}
... ...
@@ -1183,13 +1183,13 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag
1183 1183
 							html_tag_arg_add(hrefs, "iframe", arg_value);
1184 1184
 							if(hrefs->scanContents && in_ahref)
1185 1185
 								/* see above */
1186
-								hrefs->contents[hrefs->count-1] = cli_strdup(hrefs->value[in_ahref-1]);
1186
+								hrefs->contents[hrefs->count-1] = (unsigned char*)cli_strdup((const char*)hrefs->value[in_ahref-1]);
1187 1187
 							if (in_form_action) {
1188 1188
 								/* form action is the real URL, and href is the 'displayed' */
1189 1189
 								html_tag_arg_add(hrefs,"form",arg_value);
1190 1190
 								contents.pos = 0;
1191 1191
 								html_tag_contents_append(&contents, in_form_action,
1192
-										in_form_action + strlen(in_form_action));
1192
+										in_form_action + strlen((const char*)in_form_action));
1193 1193
 								html_tag_contents_done(hrefs, hrefs->count, &contents);
1194 1194
 							}
1195 1195
 						}
... ...
@@ -1199,13 +1199,13 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag
1199 1199
 							html_tag_arg_add(hrefs, "area", arg_value);
1200 1200
 							if(hrefs->scanContents && in_ahref)
1201 1201
 								/* see above */
1202
-								hrefs->contents[hrefs->count-1] = cli_strdup(hrefs->value[in_ahref-1]);
1202
+								hrefs->contents[hrefs->count-1] = (unsigned char*)cli_strdup((const char*)hrefs->value[in_ahref-1]);
1203 1203
 							if (in_form_action) {
1204 1204
 								/* form action is the real URL, and href is the 'displayed' */
1205 1205
 								html_tag_arg_add(hrefs,"form",arg_value);
1206 1206
 								contents.pos = 0;
1207 1207
 								html_tag_contents_append(&contents, in_form_action,
1208
-									in_form_action + strlen(in_form_action));
1208
+									in_form_action + strlen((const char*)in_form_action));
1209 1209
 								html_tag_contents_done(hrefs, hrefs->count, &contents);
1210 1210
 							}
1211 1211
 						}
... ...
@@ -1215,14 +1215,14 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag
1215 1215
 					/* a/img tags for buff_text can be processed only if we're not processing hrefs */
1216 1216
 					arg_value = html_tag_arg_value(&tag_args, "href");
1217 1217
 					if(arg_value && arg_value[0]) {
1218
-						html_output_str(file_buff_text, arg_value, strlen(arg_value));
1218
+						html_output_str(file_buff_text, (const unsigned char*)arg_value, strlen((const char*)arg_value));
1219 1219
 						html_output_c(file_buff_text, ' ');
1220 1220
 						text_space_written = TRUE;
1221 1221
 					}
1222 1222
 				} else if (strcmp(tag, "img") == 0) {
1223 1223
 					arg_value = html_tag_arg_value(&tag_args, "src");
1224 1224
 					if(arg_value && arg_value[0]) {
1225
-						html_output_str(file_buff_text, arg_value, strlen(arg_value));
1225
+						html_output_str(file_buff_text, (const unsigned char*)arg_value, strlen((const char*)arg_value));
1226 1226
 						html_output_c(file_buff_text, ' ');
1227 1227
 						text_space_written = TRUE;
1228 1228
 					}
... ...
@@ -1353,7 +1353,7 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag
1353 1353
 				break;
1354 1354
 			case HTML_LOOKFOR_SCRENC:
1355 1355
 				look_for_screnc = TRUE;
1356
-				ptr_screnc = strstr(ptr, "#@~^");
1356
+				ptr_screnc = (unsigned char*)strstr((char*)ptr, "#@~^");
1357 1357
 				if(ptr_screnc) {
1358 1358
 					ptr_screnc[0] = '/';
1359 1359
 					ptr_screnc[1] = '/';
... ...
@@ -1364,7 +1364,7 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag
1364 1364
 				break;
1365 1365
 			case HTML_JSDECODE:
1366 1366
 				/* Check for start marker */
1367
-				if (strncmp(ptr, "#@~^", 4) == 0) {
1367
+				if (strncmp((const char*)ptr, "#@~^", 4) == 0) {
1368 1368
 					ptr[0] = '/';
1369 1369
 					ptr[1] = '/';
1370 1370
 					ptr += 4;
... ...
@@ -1376,7 +1376,7 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag
1376 1376
 				}
1377 1377
 				break;
1378 1378
 			case HTML_JSDECODE_LENGTH:
1379
-				if (strlen(ptr) < 8) {
1379
+				if (strlen((const char*)ptr) < 8) {
1380 1380
 					state = HTML_NORM;
1381 1381
 					next_state = HTML_BAD_STATE;
1382 1382
 					break;
... ...
@@ -1498,15 +1498,15 @@ static int cli_html_normalise(int fd, m_area_t *m_area, const char *dirname, tag
1498 1498
 					}
1499 1499
 					file_tmp_o1->length = 0;
1500 1500
 
1501
-					html_output_str(file_tmp_o1, "From html-normalise\n", 20);
1502
-					html_output_str(file_tmp_o1, "Content-type: ", 14);
1501
+					html_output_str(file_tmp_o1, (const unsigned char*)"From html-normalise\n", 20);
1502
+					html_output_str(file_tmp_o1, (const unsigned char*)"Content-type: ", 14);
1503 1503
 					if ((tag_val_length == 0) && (*tag_val == ';')) {
1504
-						html_output_str(file_tmp_o1, "text/plain\n", 11);
1504
+						html_output_str(file_tmp_o1, (const unsigned char*)"text/plain\n", 11);
1505 1505
 					}
1506
-					html_output_str(file_tmp_o1, tag_val, tag_val_length);
1506
+					html_output_str(file_tmp_o1, (const unsigned char*)tag_val, tag_val_length);
1507 1507
 					html_output_c(file_tmp_o1, '\n');
1508 1508
 					if (strstr(tag_val, ";base64") != NULL) {
1509
-						html_output_str(file_tmp_o1, "Content-transfer-encoding: base64\n", 34);
1509
+						html_output_str(file_tmp_o1, (const unsigned char*)"Content-transfer-encoding: base64\n", 34);
1510 1510
 					}
1511 1511
 					html_output_c(file_tmp_o1, '\n');
1512 1512
 				} else {
... ...
@@ -1751,8 +1751,8 @@ int html_screnc_decode(int fd, const char *dirname)
1751 1751
 		return FALSE;
1752 1752
 	}
1753 1753
 
1754
-	snprintf(filename, 1024, "%s/screnc.html", dirname);
1755
-	ofd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IRUSR);
1754
+	snprintf((char*)filename, 1024, "%s/screnc.html", dirname);
1755
+	ofd = open((const char*)filename, O_WRONLY|O_CREAT|O_TRUNC, S_IWUSR|S_IRUSR);
1756 1756
 
1757 1757
 	if (ofd < 0) {
1758 1758
 		cli_dbgmsg("open failed: %s\n", filename);
... ...
@@ -1761,7 +1761,7 @@ int html_screnc_decode(int fd, const char *dirname)
1761 1761
 	}
1762 1762
 
1763 1763
 	while ((line = cli_readchunk(stream_in, NULL, 8192)) != NULL) {
1764
-		ptr = strstr(line, "#@~^");
1764
+		ptr = (unsigned char*)strstr((char*)line, "#@~^");
1765 1765
 		if (ptr) {
1766 1766
 			break;
1767 1767
 		}
... ...
@@ -1801,7 +1801,7 @@ int html_screnc_decode(int fd, const char *dirname)
1801 1801
 	cli_writen(ofd, "<script>",strlen("<script>"));
1802 1802
 	while (screnc_state.length && line) {
1803 1803
 		screnc_decode(ptr, &screnc_state);
1804
-		cli_writen(ofd, ptr, strlen(ptr));
1804
+		cli_writen(ofd, ptr, strlen((const char*)ptr));
1805 1805
 		free(line);
1806 1806
 		if (screnc_state.length) {
1807 1807
 			ptr = line = cli_readchunk(stream_in, NULL, 8192);
... ...
@@ -866,6 +866,8 @@ void cli_js_parse_done(struct parser_state* state)
866 866
 		case SingleQString:
867 867
 			end = '\'';
868 868
 			break;
869
+		default: /* make gcc happy */
870
+			break;
869 871
 	}
870 872
 	if (end != '\0')
871 873
 		cli_js_process_buffer(state, &end, 1);
... ...
@@ -1557,6 +1559,8 @@ static int yylex(YYSTYPE *lvalp, yyscan_t  scanner)
1557 1557
 				}
1558 1558
 				scanner->state = Initial;
1559 1559
 				break;
1560
+			default:
1561
+				assert(0 && "Not reached");
1560 1562
 		}
1561 1563
 	}
1562 1564
 	return 0;
... ...
@@ -571,7 +571,7 @@ char *cli_mp_strdup(mp_t *mp, const char *s) {
571 571
   return alloc;
572 572
 }
573 573
 
574
-char *cli_mp_virname(mp_t *mp, char *virname, unsigned int official) {
574
+char *cli_mp_virname(mp_t *mp, const char *virname, unsigned int official) {
575 575
   char *newname, *pt;
576 576
   if(!virname)
577 577
     return NULL;
... ...
@@ -34,7 +34,7 @@ void *mp_realloc(mp_t *mp, void *ptr, size_t size);
34 34
 void *mp_realloc2(mp_t *mp, void *ptr, size_t size);
35 35
 unsigned char *cli_mp_hex2str(mp_t* mp, const unsigned char *src);
36 36
 char *cli_mp_strdup(mp_t *mp, const char *s);
37
-char *cli_mp_virname(mp_t *mp, char *virname, unsigned int official);
37
+char *cli_mp_virname(mp_t *mp, const char *virname, unsigned int official);
38 38
 uint16_t *cli_mp_hex2ui(mp_t *mp, const char *hex);
39 39
 void mp_flush(mp_t *mp);
40 40
 int mp_getstats(const struct cl_engine *engine, size_t *used, size_t *total);
... ...
@@ -905,7 +905,7 @@ int cli_scanpe(int desc, cli_ctx *ctx)
905 905
     epsize = cli_readn(desc, epbuff, 4096);
906 906
 
907 907
     CLI_UNPTEMP("DISASM",(exe_sections,0));
908
-    disasmbuf(epbuff, epsize, ndesc);
908
+    disasmbuf((unsigned char*)epbuff, epsize, ndesc);
909 909
     lseek(ndesc, 0, SEEK_SET);
910 910
     ret = cli_scandesc(ndesc, ctx, CL_TYPE_PE_DISASM, 1, NULL, AC_SCAN_VIR);
911 911
     close(ndesc);
... ...
@@ -785,7 +785,7 @@ int phishingScan(const char* dir,cli_ctx* ctx,tag_arguments_t* hrefs)
785 785
 				urls.always_check_flags |= CHECK_CLOAKING;
786 786
 			}
787 787
 			string_init_c(&urls.realLink,(char*)hrefs->value[i]);
788
-			string_init_c(&urls.displayLink, hrefs->contents[i]);
788
+			string_init_c(&urls.displayLink, (char*)hrefs->contents[i]);
789 789
 			string_init_c(&urls.pre_fixup.pre_displayLink, NULL);
790 790
 
791 791
 			urls.realLink.refcount=-1;
... ...
@@ -961,8 +961,8 @@ static const uint8_t URI_xpalpha_nodot[256] = {
961 961
 
962 962
 static inline int validate_uri_xalphas_nodot(const char *start, const char *end)
963 963
 {
964
-	const unsigned char *p = start;
965
-	for(p=start;p < (const unsigned char*)end; p++) {
964
+	const unsigned char *p;
965
+	for(p=(const unsigned char*)start;p < (const unsigned char*)end; p++) {
966 966
 		if(!URI_xalpha_nodot[*p])
967 967
 			return 0;
968 968
 	}
... ...
@@ -971,8 +971,8 @@ static inline int validate_uri_xalphas_nodot(const char *start, const char *end)
971 971
 
972 972
 static inline int validate_uri_xpalphas_nodot(const char *start, const char *end)
973 973
 {
974
-	const unsigned char *p = start;
975
-	for(p=start;p < (const unsigned char*)end; p++) {
974
+	const unsigned char *p;
975
+	for(p=(const unsigned char*)start;p < (const unsigned char*)end; p++) {
976 976
 		if(!URI_xpalpha_nodot[*p])
977 977
 			return 0;
978 978
 	}
... ...
@@ -983,7 +983,7 @@ static inline int validate_uri_xpalphas_nodot(const char *start, const char *end
983 983
 
984 984
 static inline int validate_uri_ialpha(const char *start, const char *end)
985 985
 {
986
-	const unsigned char *p = start;
986
+	const unsigned char *p = (const unsigned char*) start;
987 987
 	if(start >= end || !URI_alpha[*p])
988 988
 		return 0;
989 989
 	return validate_uri_xalphas_nodot(start + 1, end);
... ...
@@ -994,7 +994,6 @@ static inline int validate_uri_ialpha(const char *start, const char *end)
994 994
  */
995 995
 static int isURL(const struct phishcheck* pchk,const char* URL, int accept_anyproto)
996 996
 {
997
-	size_t len;
998 997
 	const char *start = NULL, *p, *q, *end;
999 998
 	if(!URL)
1000 999
 		return 0;
... ...
@@ -1154,7 +1154,7 @@ static int cli_loadftm(FILE *fs, struct cl_engine **engine, unsigned int options
1154 1154
 static int cli_loadign(FILE *fs, struct cl_engine **engine, unsigned int options, struct cli_dbio *dbio)
1155 1155
 {
1156 1156
 	const char *tokens[IGN_TOKENS];
1157
-	char buffer[FILEBUFF], *pt;
1157
+	char buffer[FILEBUFF];
1158 1158
 	unsigned int line = 0;
1159 1159
 	struct cli_ignsig *new;
1160 1160
 	struct cli_ignored *ignored;
... ...
@@ -1398,7 +1398,7 @@ static int cli_loadmd5(FILE *fs, struct cl_engine **engine, unsigned int *signo,
1398 1398
 static int cli_loadmd(FILE *fs, struct cl_engine **engine, unsigned int *signo, int type, unsigned int options, struct cli_dbio *dbio, const char *dbname)
1399 1399
 {
1400 1400
 	const char *tokens[MD_TOKENS];
1401
-	char buffer[FILEBUFF], *pt;
1401
+	char buffer[FILEBUFF];
1402 1402
 	unsigned int line = 0, sigs = 0;
1403 1403
 	int ret = CL_SUCCESS, crc;
1404 1404
 	struct cli_meta_node *new;
... ...
@@ -56,7 +56,7 @@ enum { UPACK_399, UPACK_11_12, UPACK_0151477, UPACK_0297729 };
56 56
 int unupack(int upack, char *dest, uint32_t dsize, char *buff, uint32_t vma, uint32_t ep, uint32_t base, uint32_t va, int file)
57 57
 {
58 58
 	int j, searchval;
59
-	char *loc_esi, *loc_edi, *loc_ebx, *end_edi, *save_edi, *alvalue;
59
+	char *loc_esi, *loc_edi = NULL, *loc_ebx, *end_edi, *save_edi, *alvalue;
60 60
 	char *paddr, *pushed_esi, *save2;
61 61
 	uint32_t save1, save3, loc_ecx, count, shlsize, original_ep, ret, loc_ebx_u;
62 62
 	struct cli_exe_section section;
... ...
@@ -530,8 +530,8 @@ int upx_inflatelzma(char *src, uint32_t ssize, char *dst, uint32_t *dsize, uint3
530 530
   cli_LzmaInitUPX(&lz, *dsize);
531 531
   s.avail_in = ssize;
532 532
   s.avail_out = *dsize;
533
-  s.next_in = src+2;
534
-  s.next_out = dst;
533
+  s.next_in = (unsigned char*)src+2;
534
+  s.next_out = (unsigned char*)dst;
535 535
 
536 536
   if(cli_LzmaDecode(&lz, &s)==LZMA_RESULT_DATA_ERROR) {
537 537
 /*     __asm__ __volatile__("int3"); */
... ...
@@ -917,7 +917,7 @@ static int rar_unpack29(int fd, int solid, unpack_data_t *unpack_data)
917 917
 					continue;
918 918
 				}
919 919
 				if (next_ch == 4) {
920
-					unsigned int length;
920
+					unsigned int length = 0;
921 921
 					distance = 0;
922 922
 					failed = FALSE;
923 923
 					for (i=0 ; i < 4 && !failed; i++) {
... ...
@@ -562,6 +562,8 @@ static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_fil
562 562
 		SET_VALUE(FALSE, &rarvm_data->mem[VM_GLOBALMEMADDR+0x1c], dest_pos-data_size);
563 563
 		SET_VALUE(FALSE, &rarvm_data->mem[VM_GLOBALMEMADDR+0x20], data_size);
564 564
 		break;
565
+	default: /* make gcc happy */
566
+		break;
565 567
 	}
566 568
 }
567 569
 				
... ...
@@ -989,6 +991,8 @@ static void rarvm_optimize(struct rarvm_prepared_program *prg)
989 989
 			case VM_CMP:
990 990
 				cmd->op_code = cmd->byte_mode ? VM_CMPB:VM_CMPD;
991 991
 				continue;
992
+			default: /* make gcc happy */
993
+				break;
992 994
 		}
993 995
 		if ((vm_cmdflags[cmd->op_code] & VMCF_CHFLAGS) == 0) {
994 996
 			continue;
... ...
@@ -1023,6 +1027,8 @@ static void rarvm_optimize(struct rarvm_prepared_program *prg)
1023 1023
 			case VM_NEG:
1024 1024
 				cmd->op_code = cmd->byte_mode ? VM_NEGB:VM_NEGD;
1025 1025
 				continue;
1026
+			default: /* make gcc happy */
1027
+				break;
1026 1028
 		}
1027 1029
 	}
1028 1030
 }
... ...
@@ -185,7 +185,7 @@ static unrar_fileheader_t *read_block(int fd, header_type hdr_type)
185 185
     unrar_dbgmsg("UNRAR: Pack Size: %u\n", file_header->pack_size);
186 186
     unrar_dbgmsg("UNRAR: UnPack Version: 0x%.2x\n", file_header->unpack_ver);
187 187
     unrar_dbgmsg("UNRAR: Pack Method: 0x%.2x\n", file_header->method);
188
-    file_header->filename = (char *) malloc(file_header->name_size+1);
188
+    file_header->filename = (unsigned char *) malloc(file_header->name_size+1);
189 189
     if(!file_header->filename) {
190 190
 	free(file_header);
191 191
 	return NULL;
... ...
@@ -393,7 +393,7 @@ int unrar_extract_next_prepare(unrar_state_t *state, const char *dirname)
393 393
     new_metadata->unpack_size = state->file_header->high_unpack_size * 0x100000000ULL + state->file_header->unpack_size;
394 394
     new_metadata->crc = state->file_header->file_crc;
395 395
     new_metadata->method = state->file_header->method;
396
-    new_metadata->filename = strdup(state->file_header->filename);
396
+    new_metadata->filename = strdup((const char*)state->file_header->filename);
397 397
     if(!new_metadata->filename) {
398 398
 	free(new_metadata);
399 399
 	return UNRAR_EMEM;