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
LINK(server)->s_state = IRCS_CONNECTING;
/* change nick on client */
int i;
unsigned int i;
for (i = 0; i < LINK(server)->l_clientc; i++) {
struct link_client *c = LINK(server)->l_clientv[i];
WRITE_LINE1(CONN(c), LINK(server)->cli_nick, "NICK",
......
static void irc_server_connected(struct link_server *server)
{
int i;
unsigned int i;
LINK(server)->s_state = IRCS_CONNECTED;
LINK(server)->s_conn_attempt = 0;
......
void rotate_who_client(struct link *link)
{
int i;
unsigned int i;
mylog(LOG_DEBUG, "rotate_who_client %p", link->who_client);
/* find a client with non-null who_count */
link->who_client = NULL;
......
}
if (ret == OK_COPY) {
int i;
unsigned int i;
for (i = 0; i < LINK(server)->l_clientc; i++) {
if (TYPE(LINK(server)->l_clientv[i]) ==
IRC_TYPE_CLIENT) {
......
static void bind_to_link(struct link *l, struct link_client *ic)
{
int i = l->l_clientc;
unsigned int i = l->l_clientc;
LINK(ic) = l;
l->l_clientc++;
......
void unbind_from_link(struct link_client *ic)
{
struct link *l = LINK(ic);
int i;
unsigned int i;
for (i = 0; i < l->l_clientc; i++)
if (l->l_clientv[i] == ic)
......
for (i = i + 1; i < l->l_clientc; i++)
l->l_clientv[i - 1] = l->l_clientv[i];
if (l->l_clientc == 0)
fatal("unbind_from_link: negative client count");
l->l_clientc--;
l->l_clientv = bip_realloc(l->l_clientv, l->l_clientc *
sizeof(struct link_client *));
......
static void irc_notify_disconnection(struct link_server *is)
{
int i;
unsigned int i;
LINK(is)->cli_nick = bip_strdup(is->nick);
for (i = 0; i < LINK(is)->l_clientc; i++) {
......
ci = hash_get(&LINK(ircs)->chan_infos, chan);
if (!ci) {
struct chan_info *ci;
ci = chan_info_new();
ci->name = bip_strdup(chan);
ci->key = key ? bip_strdup(key) : NULL;
......
free(str);
if (r == OK_COPY_CLI) {
int i;
unsigned int i;
struct link_server *s = LINK(ic)->l_server;
for (i = 0; i < LINK(s)->l_clientc; i++)
src/irc.h
/** link live data **/
struct link_server *l_server;
int l_clientc;
unsigned int l_clientc;
struct link_client **l_clientv;
struct log *log;
(10-10/24)