Project

General

Profile

Enhancement #750 » 0011-sanitize-link_server-l_clientc-should-not-be-allowed.patch

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

View differences:

src/irc.c
167 167
		LINK(server)->s_state = IRCS_CONNECTING;
168 168

  
169 169
	/* change nick on client */
170
	int i;
170
	unsigned int i;
171 171
	for (i = 0; i < LINK(server)->l_clientc; i++) {
172 172
		struct link_client *c = LINK(server)->l_clientv[i];
173 173
		WRITE_LINE1(CONN(c), LINK(server)->cli_nick, "NICK",
......
223 223

  
224 224
static void irc_server_connected(struct link_server *server)
225 225
{
226
	int i;
226
	unsigned int i;
227 227

  
228 228
        LINK(server)->s_state = IRCS_CONNECTED;
229 229
        LINK(server)->s_conn_attempt = 0;
......
338 338

  
339 339
void rotate_who_client(struct link *link)
340 340
{
341
	int i;
341
	unsigned int i;
342 342
	mylog(LOG_DEBUG, "rotate_who_client %p", link->who_client);
343 343
	/* find a client with non-null who_count */
344 344
	link->who_client = NULL;
......
582 582
	}
583 583

  
584 584
	if (ret == OK_COPY) {
585
		int i;
585
		unsigned int i;
586 586
		for (i = 0; i < LINK(server)->l_clientc; i++) {
587 587
			if (TYPE(LINK(server)->l_clientv[i]) ==
588 588
					IRC_TYPE_CLIENT) {
......
659 659

  
660 660
static void bind_to_link(struct link *l, struct link_client *ic)
661 661
{
662
	int i = l->l_clientc;
662
	unsigned int i = l->l_clientc;
663 663

  
664 664
	LINK(ic) = l;
665 665
	l->l_clientc++;
......
671 671
void unbind_from_link(struct link_client *ic)
672 672
{
673 673
	struct link *l = LINK(ic);
674
	int i;
674
	unsigned int i;
675 675

  
676 676
	for (i = 0; i < l->l_clientc; i++)
677 677
		if (l->l_clientv[i] == ic)
......
688 688
	for (i = i + 1; i < l->l_clientc; i++)
689 689
		l->l_clientv[i - 1] = l->l_clientv[i];
690 690

  
691
	if (l->l_clientc == 0)
692
		fatal("unbind_from_link: negative client count");
691 693
	l->l_clientc--;
692 694
	l->l_clientv = bip_realloc(l->l_clientv, l->l_clientc *
693 695
			sizeof(struct link_client *));
......
1068 1070

  
1069 1071
static void irc_notify_disconnection(struct link_server *is)
1070 1072
{
1071
	int i;
1073
	unsigned int i;
1072 1074
	LINK(is)->cli_nick = bip_strdup(is->nick);
1073 1075

  
1074 1076
	for (i = 0; i < LINK(is)->l_clientc; i++) {
......
1094 1096

  
1095 1097
	ci = hash_get(&LINK(ircs)->chan_infos, chan);
1096 1098
	if (!ci) {
1097
		struct chan_info *ci;
1098 1099
		ci = chan_info_new();
1099 1100
		ci->name = bip_strdup(chan);
1100 1101
		ci->key = key ? bip_strdup(key) : NULL;
......
1250 1251

  
1251 1252
		free(str);
1252 1253
		if (r == OK_COPY_CLI) {
1253
			int i;
1254
			unsigned int i;
1254 1255
			struct link_server *s = LINK(ic)->l_server;
1255 1256

  
1256 1257
			for (i = 0; i < LINK(s)->l_clientc; i++)
src/irc.h
114 114

  
115 115
	/** link live data **/
116 116
	struct link_server *l_server;
117
	int l_clientc;
117
	unsigned int l_clientc;
118 118
	struct link_client **l_clientv;
119 119

  
120 120
	struct log *log;
121
- 
(10-10/24)