Project

General

Profile

Bug #265 » 0001-Don-t-use-splitted-string-after-PASS-.-Fix-265.patch

Pierre-Louis Bonicoli, 2011-12-20 05:09

View differences:

src/irc.c
static int irc_cli_pass(bip_t *bip, struct link_client *ic, struct line *line)
{
if (irc_line_count(line) != 2)
int len = 0;
int nb_spaces;
int i;
if ((irc_line_count(line) < 2)
|| !irc_line_elem_case_equals(line, 0, "PASS"))
return ERR_PROTOCOL;
if ((ic->state & IRCC_READY) == IRCC_READY)
return ERR_PROTOCOL;
ic->state |= IRCC_PASS;
if (ic->init_pass)
if (ic->init_pass) {
free(ic->init_pass);
ic->init_pass = bip_strdup(irc_line_elem(line, 1));
if ((ic->state & IRCC_READY) == IRCC_READY)
ic->init_pass = NULL;
}
// concat all words except prefix: "PASS"
for (i = 1; i < array_count(&line->words); i++) {
len += strlen(array_get(&line->words, i));
}
nb_spaces = array_count(&line->words) - 2;
len += nb_spaces + 1;
ic->init_pass = bip_malloc(len);
ic->init_pass[0] = 0;
for (i = 1; i < array_count(&line->words) - 1; i++) {
strcat(ic->init_pass, array_get(&line->words, i));
strcat(ic->init_pass, " ");
}
strcat(ic->init_pass, array_get(&line->words, i));
if ((ic->state & IRCC_READY) == IRCC_READY) {
return irc_cli_startup(bip, ic, line);
}
return OK_FORGET;
}
(1-1/2)