Project

General

Profile

Enhancement #750 » 0006-sanitize-trivial-fixes-and-casts-to-types-expected-b.patch

Loïc Gomez, 2022-01-10 19:27

View differences:

src/bip.c
78 78
	if (strlen(hex) != 40)
79 79
		fatal("Incorrect password format %s\n", hex);
80 80

  
81
	md5 = bip_malloc(20);
81
	md5 = bip_malloc((size_t) 20);
82 82
	for (i = 0; i < 20; i++) {
83 83
		sscanf(hex + 2 * i, "%02x", &buf);
84 84
		md5[i] = buf;
......
174 174
	f = fopen(conf_pid_file, "r");
175 175
	if (f)
176 176
		goto pid_is_there;
177
	if (gethostname(hname, 511) == -1)
177
	if (gethostname(hname, (size_t)511) == -1)
178 178
		fatal("%s %s", "gethostname", strerror(errno));
179 179
	hname[511] = 0;
180 180
	snprintf(longpath, longpath_max - 1, "%s.%s.%ld", conf_pid_file, hname,
......
298 298
		n->serverv = NULL;
299 299
		n->serverc = 0;
300 300
	} else {
301
		n = bip_calloc(sizeof(struct network), 1);
301
		n = bip_calloc(sizeof(struct network), (size_t)1);
302 302
		hash_insert(&bip->networks, name, n);
303 303
	}
304 304

  
......
526 526
				case LEX_BACKLOG:
527 527
					ci->backlog = t2->ndata;
528 528
					break;
529
				default:
530
					conf_die(bip, "Unknown keyword in channel block (%d)",
531
							t2->type);
532
					return 0;
529 533
				}
530 534
				if (t2->tuple_type == TUPLE_STR && t2->pdata)
531 535
					free(t2->pdata);
......
693 697
	}
694 698
	u = hash_get(&bip->users, name);
695 699
	if (!u) {
696
		u = bip_calloc(sizeof(struct bipuser), 1);
700
		u = bip_calloc(sizeof(struct bipuser), (size_t) 1);
697 701
		hash_insert(&bip->users, name, u);
698 702
		hash_init(&u->connections, HASH_NOCASE);
699 703
		u->admin = 0;
......
1756 1760
	else
1757 1761
		nick = LINK(ic)->prev_nick;
1758 1762

  
1759
	vsnprintf(str, 4095, fmt, ap);
1763
	vsnprintf(str, (size_t)4095, fmt, ap);
1760 1764
	str[4095] = 0;
1761 1765
	WRITE_LINE2(CONN(ic), P_IRCMASK, (LINK(ic)->user->bip_use_notice ?
1762 1766
				"NOTICE" : "PRIVMSG"), nick, str);
src/bip_main.c
98 98
	if (conf_log_system && conf_daemonize) {
99 99
		if (conf_global_log_file && conf_global_log_file != stderr)
100 100
			fclose(conf_global_log_file);
101
		snprintf(buf, 4095, "%s/bip.log", conf_log_root);
101
		snprintf(buf, (size_t) 4095, "%s/bip.log", conf_log_root);
102 102
		FILE *f = fopen(buf, "a");
103 103
		if (!f)
104 104
			fatal("Can't open %s: %s", buf, strerror(errno));
......
294 294
		pid = daemonize();
295 295
	else
296 296
		pid = getpid();
297
	snprintf(buf, 29, "%ld\n", (long unsigned int)pid);
297
	snprintf(buf, (size_t) 29, "%lu\n", (unsigned long int)pid);
298 298
	write(fd, buf, strlen(buf));
299 299
	close(fd);
300 300

  
src/connection.c
319 319
	 * Shitty: we might have written a partial line, so we hack the line...
320 320
	 * Callers of _write_socket muse provide a writable message
321 321
	 */
322
// this might be the same
323
#if EWOULDBLOCK == EAGAIN
324
	if (errno == EAGAIN || errno == EINPROGRESS) {
325
#else
322 326
	if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINPROGRESS) {
327
#endif
323 328
		memmove(message, message + tcount, size - tcount + 1);
324 329
		return WRITE_KEEP;
325 330
	}
......
1101 1106
	char *incoming;
1102 1107
	list_t *outgoing;
1103 1108

  
1104
	conn = (connection_t *)bip_calloc(sizeof(connection_t), 1);
1105
	incoming = (char *)bip_malloc(CONN_BUFFER_SIZE);
1109
	conn = (connection_t *)bip_calloc(sizeof(connection_t), (size_t)1);
1110
	incoming = (char *)bip_malloc((size_t)CONN_BUFFER_SIZE);
1106 1111
	outgoing = list_new(NULL);
1107 1112

  
1108 1113
	conn->anti_flood = anti_flood;
......
1260 1265
	connection_t *conn;
1261 1266
	char portbuf[20];
1262 1267
	/* TODO: allow litteral service name in the function interface */
1263
	if (snprintf(portbuf, 20, "%d", port) >= 20)
1268
	if (snprintf(portbuf, (size_t)20, "%d", port) >= 20)
1264 1269
		portbuf[19] = '\0';
1265 1270

  
1266 1271
	/*
......
1296 1301
		SSL_load_error_strings();
1297 1302
		errbio = BIO_new_fp(conf_global_log_file, BIO_NOCLOSE);
1298 1303

  
1299
		ssl_cx_idx = SSL_get_ex_new_index(0, "bip connection_t",
1304
		ssl_cx_idx = SSL_get_ex_new_index((size_t)0, "bip connection_t",
1300 1305
			NULL, NULL,NULL);
1301 1306

  
1302 1307
		flags = O_RDONLY;
......
1309 1314
		}
1310 1315

  
1311 1316
		do {
1312
			ret = read(fd, buf, 1024);
1317
			ret = read(fd, buf, (size_t)1024);
1313 1318
			if (ret <= 0) {
1314 1319
				mylog(LOG_ERROR,"/dev/random: %s",
1315 1320
						strerror(errno));
......
1573 1578
		mylog(LOG_ERROR, "Can't open SSL certificate check store! Check path "
1574 1579
				"and permissions.");
1575 1580
		return conn;
1581
	default:
1582
		fatal("Unknown SSL cert check mode.");
1576 1583
	}
1577 1584

  
1578 1585
	switch (conn->ssl_check_mode) {
......
1639 1646
	(void)ssl_client_certfile;
1640 1647
#endif
1641 1648
	/* TODO: allow litteral service name in the function interface */
1642
	if (snprintf(dstportbuf, 20, "%d", dstport) >= 20)
1649
	if (snprintf(dstportbuf, (size_t)20, "%d", dstport) >= 20)
1643 1650
		dstportbuf[19] = '\0';
1644 1651
	if (srcport) {
1645
		if (snprintf(srcportbuf, 20, "%d", srcport) >= 20)
1652
		if (snprintf(srcportbuf, (size_t)20, "%d", srcport) >= 20)
1646 1653
			srcportbuf[19] = '\0';
1647 1654
		tmp = srcportbuf;
1648 1655
	} else
......
1807 1814
		return NULL;
1808 1815
	}
1809 1816

  
1810
	ip = bip_malloc(65);
1817
	ip = bip_malloc((size_t)65);
1811 1818

  
1812 1819
	switch (addr.sa_family) {
1813 1820
	case AF_INET:
src/irc.c
81 81
struct channel *channel_new(const char *name)
82 82
{
83 83
	struct channel *chan;
84
	chan = bip_calloc(sizeof(struct channel), 1);
84
	chan = bip_calloc(sizeof(struct channel), (size_t)1);
85 85
	chan->name = bip_strdup(name);
86 86
	hash_init(&chan->ovmasks, HASH_NOCASE);
87 87
	return chan;
......
113 113
	list_t *ret;
114 114
	hash_iterator_t hi;
115 115
	size_t len = 0;
116
	char *str = bip_malloc(NAMESIZE + 1);
116
	char *str = bip_malloc((size_t)(NAMESIZE + 1));
117 117

  
118 118
	ret = list_new(NULL);
119 119
	*str = 0;
......
126 126

  
127 127
		if (len + strlen(nick) + 2 + (ovmask ? 1 : 0) >= NAMESIZE) {
128 128
			list_add_last(ret, str);
129
			str = bip_malloc(NAMESIZE + 1);
129
			str = bip_malloc((size_t)(NAMESIZE + 1));
130 130
			*str = 0;
131 131
			len = 0;
132 132
		}
......
249 249
	list_iterator_t itocs;
250 250
	for (list_it_init(&LINK(server)->on_connect_send, &itocs);
251 251
				list_it_item(&itocs); list_it_next(&itocs)) {
252
		ssize_t len = strlen(list_it_item(&itocs)) + 2;
252
		size_t len = strlen(list_it_item(&itocs)) + 2;
253 253
		char *str = bip_malloc(len + 1);
254 254
		sprintf(str, "%s\r\n", (char *)list_it_item(&itocs));
255 255
		write_line(CONN(server), str);
......
516 516
				if (LINK(server)->ignore_server_capab &&
517 517
						irc_line_elem_equals(line, i, "CAPAB"))
518 518
					irc_line_drop(line, i);
519
				else if (!strncmp(irc_line_elem(line, i), "CHANMODES=", 10))
519
				else if (!strncmp(irc_line_elem(line, i), "CHANMODES=", (size_t)10))
520 520
					server_set_chanmodes(server, irc_line_elem(line, i) + 10);
521
				else if (!strncmp(irc_line_elem(line, i), "PREFIX=(", 8))
521
				else if (!strncmp(irc_line_elem(line, i), "PREFIX=(", (size_t)8))
522 522
					server_set_prefix(server, irc_line_elem(line, i) + 7);
523 523
			}
524 524
		}
......
1789 1789

  
1790 1790
static char *irc_timestamp(void)
1791 1791
{
1792
	char *ts = bip_malloc(21);
1793
	snprintf(ts, 20, "%ld", (long int)time(NULL));
1792
	char *ts = bip_malloc((size_t)23);
1793
	snprintf(ts, (size_t)22, "%ld", (long int)time(NULL));
1794 1794
	return ts;
1795 1795
}
1796 1796

  
......
2148 2148
	if (!newconn)
2149 2149
		return NULL;
2150 2150

  
2151
	ircc = bip_calloc(sizeof(struct link_client), 1);
2151
	ircc = bip_calloc(sizeof(struct link_client), (size_t)1);
2152 2152
	CONN(ircc) = newconn;
2153 2153
	TYPE(ircc) = IRC_TYPE_LOGGING_CLIENT;
2154 2154
	CONN(ircc)->user_data = ircc;
......
2253 2253
{
2254 2254
	struct link_client *c;
2255 2255

  
2256
	c = bip_calloc(sizeof(struct link_client), 1);
2256
	c = bip_calloc(sizeof(struct link_client), (size_t)1);
2257 2257
	list_init(&c->who_queue, list_ptr_cmp);
2258 2258

  
2259 2259
	return c;
......
2263 2263
{
2264 2264
	struct link_server *s;
2265 2265

  
2266
	s = bip_calloc(sizeof(struct link_server), 1);
2266
	s = bip_calloc(sizeof(struct link_server), (size_t)1);
2267 2267

  
2268 2268
	TYPE(s) = IRC_TYPE_SERVER;
2269 2269
	hash_init(&s->channels, HASH_NOCASE);
......
2444 2444

  
2445 2445
		content = (char *)bip_malloc(stats.st_size + 1);
2446 2446

  
2447
		if (fread(content, 1, stats.st_size, f) !=
2447
		if (fread(content, (size_t)1, stats.st_size, f) !=
2448 2448
				(size_t)stats.st_size) {
2449 2449
			mylog(LOG_WARN, "Can't read %s fully",
2450 2450
					bip->oidentdpath);
......
2457 2457

  
2458 2458
		bipstart = strstr(content, BIP_OIDENTD_START);
2459 2459
		if (bipstart != NULL) {
2460
			/* We have some config left, rewrite the file
2461
			 * completely */
2462
			fseek(f, SEEK_SET, 0);
2463
			if (ftruncate(fileno(f), 0) == -1) {
2460
			// We have some config left, rewrite the file completely
2461
			fseek(f, (long)SEEK_SET, (int)0);
2462
			if (ftruncate(fileno(f), (off_t)0) == -1) {
2464 2463
				mylog(LOG_DEBUG, "Can't reset %s size",
2465 2464
						bip->oidentdpath);
2466 2465
				free(content);
......
2755 2754
struct link *irc_link_new(void)
2756 2755
{
2757 2756
	struct link *link;
2758
	link = bip_calloc(sizeof(struct link), 1);
2757
	link = bip_calloc(sizeof(struct link), (size_t)1);
2759 2758

  
2760 2759
	link->l_server = NULL;
2761 2760
	hash_init(&link->chan_infos, HASH_NOCASE);
......
2844 2843
			modes = cur + 1;
2845 2844
		} else {
2846 2845
			// emptry string
2847
			dup = bip_calloc(1, sizeof(char));
2846
			dup = bip_calloc((size_t)1, sizeof(char));
2848 2847
		}
2849 2848
		mylog(LOG_DEBUGVERB, "[%s] Modes: '%s'", LINK(l)->name, dup);
2850 2849
		array_push(&l->chanmodes, dup);
src/irc.h
224 224
	int backlog;
225 225
};
226 226

  
227
#define chan_info_new() bip_calloc(sizeof(struct chan_info), 1)
227
#define chan_info_new() bip_calloc(sizeof(struct chan_info), (size_t)1)
228 228

  
229 229
struct link_server {
230 230
	struct link_connection _link_c;
......
273 273
void irc_server_free(struct link_server *is);
274 274
struct client *client_new(void);
275 275
void irc_main(bip_t *);
276
int ischannel(char p);
277 276
void irc_client_close(struct link_client *);
278 277
void irc_client_free(struct link_client *);
279 278
struct link *irc_link_new(void);
src/line.h
84 84

  
85 85
void irc_line_init(struct line *l);
86 86
void _irc_line_deinit(struct line *l);
87
struct line *irc_line_new();
87
struct line *irc_line_new(void);
88 88
void irc_line_write(struct line *l, connection_t *c);
89 89
void irc_line_append(struct line *l, const char *s);
90 90
struct line *irc_line_new_from_string(char *str);
src/log.c
83 83
		int slash_ok = 1;
84 84
		while (*tmp == '/') {
85 85
			if (slash_ok) {
86
				strncpy(dir + count, "/", 2);
86
				strncpy(dir + count, "/", (size_t)2);
87 87
				count++;
88 88
				slash_ok = 0;
89 89
			}
......
140 140
	char *dest = bip_strdup(destination);
141 141

  
142 142
	strtolower(dest);
143
	logfile = (char *)bip_malloc(MAX_PATH_LEN + 1);
143
	logfile = (char *)bip_malloc((size_t)MAX_PATH_LEN + 1);
144 144

  
145 145
	time(&s);
146 146
	now = localtime(&s);
147
	strftime(year, 5, "%Y", now);
148
	strftime(day, 3, "%d", now);
149
	strftime(month, 3, "%m", now);
150
	strftime(hour, 3, "%H", now);
151
	snprintf(logfile, MAX_PATH_LEN, "%s/%s", conf_log_root,
147
	strftime(year, (size_t)5, "%Y", now);
148
	strftime(day, (size_t)3, "%d", now);
149
	strftime(month, (size_t)3, "%m", now);
150
	strftime(hour, (size_t)3, "%H", now);
151
	snprintf(logfile, (size_t)MAX_PATH_LEN, "%s/%s", conf_log_root,
152 152
			conf_log_format);
153 153
	replace_var(logfile, "%u", logdata->user->name, MAX_PATH_LEN);
154 154
	replace_var(logfile, "%n", logdata->network, MAX_PATH_LEN);
......
280 280
			return 0;
281 281
		}
282 282

  
283
		if (fseek(f, 0, SEEK_END) == -1) {
283
		if (fseek(f, (long)0, SEEK_END) == -1) {
284 284
			mylog(LOG_ERROR, "fseek(%s) %s", uniq_fname,
285 285
					strerror(errno));
286 286
			free(uniq_fname);
......
299 299

  
300 300
	store = hash_get(&logdata->logfgs, destination);
301 301
	if (!store) {
302
		store = bip_calloc(sizeof(logstore_t), 1);
302
		store = bip_calloc(sizeof(logstore_t), (size_t)1);
303 303
		list_init(&store->file_group, NULL);
304 304
		store->name = bip_strdup(destination);
305 305
		store->skip_advance = 0;
......
433 433

  
434 434
void log_join(log_t *logdata, const char *ircmask, const char *channel)
435 435
{
436
	snprintf(logdata->buffer, LOGLINE_MAXLEN,
436
	snprintf(logdata->buffer, (size_t)LOGLINE_MAXLEN,
437 437
			"%s -!- %s has joined %s", timestamp(), ircmask,
438 438
			channel);
439 439
	log_write(logdata, channel, logdata->buffer);
......
443 443
		const char *message)
444 444
{
445 445
	if (message)
446
		snprintf(logdata->buffer, LOGLINE_MAXLEN,
446
		snprintf(logdata->buffer, (size_t)LOGLINE_MAXLEN,
447 447
			"%s -!- %s has left %s [%s]", timestamp(), ircmask,
448 448
			channel, message);
449 449
	else
450
		snprintf(logdata->buffer, LOGLINE_MAXLEN,
450
		snprintf(logdata->buffer, (size_t)LOGLINE_MAXLEN,
451 451
			"%s -!- %s has left %s", timestamp(), ircmask,
452 452
			channel);
453 453
	log_write(logdata, channel, logdata->buffer);
......
456 456
void log_kick(log_t *logdata, const char *ircmask, const char *channel,
457 457
		const char *who, const char *message)
458 458
{
459
	snprintf(logdata->buffer, LOGLINE_MAXLEN,
459
	snprintf(logdata->buffer, (size_t)LOGLINE_MAXLEN,
460 460
			"%s -!- %s has been kicked by %s [%s]", timestamp(),
461 461
			who, ircmask, message);
462 462
	log_write(logdata, channel, logdata->buffer);
......
465 465
void log_quit(log_t *logdata, const char *ircmask, const char *channel,
466 466
		const char *message)
467 467
{
468
	snprintf(logdata->buffer, LOGLINE_MAXLEN,
468
	snprintf(logdata->buffer, (size_t)LOGLINE_MAXLEN,
469 469
			"%s -!- %s has quit [%s]", timestamp(), ircmask,
470 470
			message);
471 471
	log_write(logdata, channel, logdata->buffer);
......
487 487
	}
488 488
	free(oldnick);
489 489

  
490
	snprintf(logdata->buffer, LOGLINE_MAXLEN,
490
	snprintf(logdata->buffer, (size_t)LOGLINE_MAXLEN,
491 491
			"%s -!- %s is now known as %s",
492 492
			timestamp(), ircmask, newnick);
493 493
	log_write(logdata, channel, logdata->buffer);
......
514 514
		if (*message == '+' || *message == '-')
515 515
			real_message++;
516 516

  
517
		if (strncmp(real_message, "\001ACTION ", 8) != 0)
517
		if (strncmp(real_message, "\001ACTION ", (size_t)8) != 0)
518 518
			return;
519 519
		msg = bip_strdup(real_message);
520 520
		*(msg + strlen(msg) - 1) = '\0';
521
		snprintf(logdata->buffer, LOGLINE_MAXLEN,
521
		snprintf(logdata->buffer, (size_t)LOGLINE_MAXLEN,
522 522
					"%s %c * %s %s", timestamp(), dir,
523 523
					from, msg + 8);
524 524
		free(msg);
525 525
	} else {
526
		snprintf(logdata->buffer, LOGLINE_MAXLEN,
526
		snprintf(logdata->buffer, (size_t)LOGLINE_MAXLEN,
527 527
					"%s %c %s: %s", timestamp(), dir,
528 528
					from, message);
529 529
	}
......
571 571
void log_topic(log_t *logdata, const char *ircmask, const char *channel,
572 572
		const char *message)
573 573
{
574
	snprintf(logdata->buffer, LOGLINE_MAXLEN,
574
	snprintf(logdata->buffer, (size_t)LOGLINE_MAXLEN,
575 575
			"%s -!- %s changed topic of %s to: %s", timestamp(),
576 576
			ircmask, channel, message);
577 577
	log_write(logdata, channel, logdata->buffer);
......
579 579

  
580 580
void log_init_topic(log_t *logdata, const char *channel, const char *message)
581 581
{
582
	snprintf(logdata->buffer, LOGLINE_MAXLEN,
582
	snprintf(logdata->buffer, (size_t)LOGLINE_MAXLEN,
583 583
			"%s -!- Topic for %s: %s", timestamp(), channel,
584 584
			message);
585 585
	log_write(logdata, channel, logdata->buffer);
......
594 594

  
595 595
	seconds = atoi(when);
596 596
	time = localtime(&seconds);
597
	timestr = (char *)bip_malloc(50 + 1);
597
	timestr = (char *)bip_malloc((size_t)50 + 1);
598 598
	timestr[0] = '\0';
599 599
	if (time)
600
		strftime(timestr, 50, "%A %d %B %Y, %H:%M:%S", time);
600
		strftime(timestr, (size_t)50, "%A %d %B %Y, %H:%M:%S", time);
601 601
	timestr[50] = '\0';
602 602

  
603
	snprintf(logdata->buffer, LOGLINE_MAXLEN,
603
	snprintf(logdata->buffer, (size_t)LOGLINE_MAXLEN,
604 604
			"%s -!- Topic set by %s [%s]", timestamp(), who,
605 605
			timestr);
606 606
	free(timestr);
......
611 611
		const char *modes, array_t *mode_args)
612 612
{
613 613
	int i;
614
	char *tmpbuf = bip_malloc(LOGLINE_MAXLEN + 1);
615
	char *tmpbuf2 = bip_malloc(LOGLINE_MAXLEN + 1);
614
	char *tmpbuf = bip_malloc((size_t)LOGLINE_MAXLEN + 1);
615
	char *tmpbuf2 = bip_malloc((size_t)LOGLINE_MAXLEN + 1);
616 616
	char *tmp;
617 617

  
618
	snprintf(tmpbuf, LOGLINE_MAXLEN, "%s -!- mode/%s [%s", timestamp(),
619
			channel, modes);
618
	snprintf(tmpbuf, (size_t)LOGLINE_MAXLEN,
619
			"%s -!- mode/%s [%s", timestamp(), channel, modes);
620 620
	if (mode_args) {
621 621
		for (i = 0; i < array_count(mode_args); i++) {
622
			snprintf(tmpbuf2, LOGLINE_MAXLEN, "%s %s", tmpbuf,
622
			snprintf(tmpbuf2, (size_t)LOGLINE_MAXLEN, "%s %s", tmpbuf,
623 623
					(char *)array_get(mode_args, i));
624 624
			tmp = tmpbuf;
625 625
			tmpbuf = tmpbuf2;
......
627 627
		}
628 628
	}
629 629

  
630
	snprintf(logdata->buffer, LOGLINE_MAXLEN, "%s] by %s", tmpbuf, ircmask);
630
	snprintf(logdata->buffer, (size_t)LOGLINE_MAXLEN, "%s] by %s",
631
			tmpbuf, ircmask);
631 632
	log_write(logdata, channel, logdata->buffer);
632 633

  
633 634
	free(tmpbuf);
......
637 638
void log_disconnected(log_t *logdata)
638 639
{
639 640
	hash_iterator_t hi;
640
	snprintf(logdata->buffer, LOGLINE_MAXLEN, "%s -!- Disconnected"
641
	snprintf(logdata->buffer, (size_t)LOGLINE_MAXLEN, "%s -!- Disconnected"
641 642
			" from server...", timestamp());
642 643
	for (hash_it_init(&logdata->logfgs, &hi); hash_it_item(&hi);
643 644
			hash_it_next(&hi))
......
649 650
	list_t *l = log_backlogs(logdata);
650 651
	char *s;
651 652

  
652
	snprintf(logdata->buffer, LOGLINE_MAXLEN,
653
	snprintf(logdata->buffer, (size_t)LOGLINE_MAXLEN,
653 654
			"%s -!- Ping timeout with server...", timestamp());
654 655
	while ((s = list_remove_first(l))) {
655 656
		log_write(logdata, s, logdata->buffer);
......
663 664
{
664 665
	hash_iterator_t hi;
665 666

  
666
	snprintf(logdata->buffer, LOGLINE_MAXLEN, "%s -!- Connected to"
667
	snprintf(logdata->buffer, (size_t)LOGLINE_MAXLEN, "%s -!- Connected to"
667 668
			" server...", timestamp());
668 669
	for (hash_it_init(&logdata->logfgs, &hi); hash_it_item(&hi);
669 670
			hash_it_next(&hi)) {
......
860 861
	lots = p - sots;
861 862
	p++;
862 863

  
863
	if (strncmp(p, "-!-", 3) == 0) {
864
	if (strncmp(p, "-!-", (size_t)3) == 0) {
864 865
		if (logdata->user->bl_msg_only)
865 866
			return NULL;
866 867
		else
......
1005 1006
		}
1006 1007
	} else {
1007 1008
		//mylog(LOG_ERROR, "bread Seeking %s to %d", lf->filename, 0);
1008
		if (fseek(lf->file, 0, SEEK_SET)) {
1009
		if (fseek(lf->file, (long)0, SEEK_SET)) {
1009 1010
			mylog(LOG_ERROR, "Can't seek in %s", lf->filename);
1010 1011
			list_add_last(res, _log_wrap(store->name,
1011 1012
						"Error seeking in logfile"));
......
1013 1014
		}
1014 1015
	}
1015 1016

  
1016
	buf = bip_malloc(LOGLINE_MAXLEN + 1);
1017
	buf = bip_malloc((size_t)LOGLINE_MAXLEN + 1);
1017 1018
	for(;;) {
1018 1019
		if (!fgets(buf, LOGLINE_MAXLEN, lf->file)) {
1019 1020
			if (ferror(lf->file)) {
......
1108 1109
	char *buf;
1109 1110
	size_t count;
1110 1111

  
1111
	buf = bip_malloc(LOGLINE_MAXLEN + 1);
1112
	count = snprintf(buf, LOGLINE_MAXLEN + 1,
1112
	buf = bip_malloc((size_t)LOGLINE_MAXLEN + 1);
1113
	count = snprintf(buf, (size_t)LOGLINE_MAXLEN + 1,
1113 1114
			":" P_IRCMASK " PRIVMSG %s :%s\r\n", dest, line);
1114 1115
	if (count >= LOGLINE_MAXLEN + 1) {
1115 1116
		mylog(LOG_DEBUG, "line too long");
......
1127 1128
	size_t len;
1128 1129
	static char tmpstr[LOGLINE_MAXLEN + 1];
1129 1130

  
1130
	strncpy(tmpstr, str, LOGLINE_MAXLEN);
1131
	strncpy(tmpstr, str, (size_t)LOGLINE_MAXLEN);
1131 1132
	tmpstr[LOGLINE_MAXLEN] = 0;
1132 1133

  
1133 1134
	if (store->memlog) {
......
1149 1150

  
1150 1151
	len = strlen(tmpstr);
1151 1152
	nbwrite = fwrite(tmpstr, sizeof(char), len, lf->file);
1152
	nbwrite += fwrite("\n", sizeof(char), 1, lf->file);
1153
	nbwrite += fwrite("\n", sizeof(char), (size_t)1, lf->file);
1153 1154
	log_updatelast(lf);
1154 1155
	if (nbwrite != len + 1)
1155 1156
		mylog(LOG_ERROR, "Error writing to %s logfile", lf->filename);
......
1202 1203
{
1203 1204
	log_t *logdata;
1204 1205

  
1205
	logdata = (log_t *)bip_calloc(sizeof(log_t), 1);
1206
	logdata = (log_t *)bip_calloc(sizeof(log_t), (size_t)1);
1206 1207
	logdata->user = user;
1207 1208
	logdata->network = bip_strdup(network);
1208 1209
	hash_init(&logdata->logfgs, HASH_NOCASE);
1209
	logdata->buffer = (char *)bip_malloc(LOGLINE_MAXLEN + 1);
1210
	logdata->buffer = (char *)bip_malloc((size_t)LOGLINE_MAXLEN + 1);
1210 1211
	logdata->buffer[LOGLINE_MAXLEN - 1] = 0; // debug
1211 1212
	logdata->buffer[LOGLINE_MAXLEN] = 0;
1212 1213
	logdata->connected = 0;
src/md5.c
238 238
    padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
239 239

  
240 240
    md5_update( ctx, md5_padding, padn );
241
    md5_update( ctx, msglen, 8 );
241
    md5_update( ctx, msglen, (unsigned long)8 );
242 242

  
243 243
    PUT_UINT32( ctx->state[0], digest,  0 );
244 244
    PUT_UINT32( ctx->state[1], digest,  4 );
......
365 365
	ptr[3] = seed & 0xff;
366 366
	memcpy(ptr + 4, str, length - 4);
367 367

  
368
	md5 = bip_malloc(16 + 4);
369
	memcpy(md5, ptr, 4);
368
	md5 = bip_malloc((size_t)16 + 4);
369
	memcpy(md5, ptr, (size_t)4);
370 370

  
371 371
	md5_starts(&ctx);
372 372
	md5_update(&ctx, ptr, length);
373 373
	md5_finish(&ctx, md5 + 4);
374 374

  
375 375
	md5_starts(&ctx);
376
	md5_update(&ctx, md5, 20);
376
	md5_update(&ctx, md5, (unsigned long)20);
377 377
	md5_finish(&ctx, md5 + 4);
378 378
	free(ptr);
379 379
	return md5;
src/util.c
35 35
{
36 36
	fflush(conf_global_log_file);
37 37
#define OOMMSG "Out of memory.\n"
38
	fwrite(OOMMSG, 1, strlen(OOMMSG), conf_global_log_file);
38
	fwrite(OOMMSG, (size_t)1, strlen(OOMMSG), conf_global_log_file);
39 39
#undef OOMMSG
40 40
	fflush(conf_global_log_file);
41 41
	exit(28);
......
198 198
	time(&tv);
199 199
	tm = localtime(&tv);
200 200

  
201
	strftime(ts, 20, "%d-%m-%Y %H:%M:%S", tm);
201
	strftime(ts, (size_t)20, "%d-%m-%Y %H:%M:%S", tm);
202 202
	return ts;
203 203
}
204 204

  
......
211 211
		return "never";
212 212
	tm = localtime(&s);
213 213

  
214
	strftime(ts, 20, "%d-%m-%Y %H:%M:%S", tm);
214
	strftime(ts, (size_t)20, "%d-%m-%Y %H:%M:%S", tm);
215 215
	return ts;
216 216
}
217 217

  
218
- 
(5-5/24)