}
/* Single channel. */
- if (args && IsChannelName(args) && !strchr(args, ','))
+ if (args && IsChannelName(args) && !strpbrk(args, "*?, "))
{
safelist_channel_named(source_p, args, operspy);
return;
if (*args == '<')
{
args++;
- if (IsDigit(*args))
- {
- params->users_max = atoi(args);
- if (params->users_max == 0)
- params->users_max = INT_MAX;
- else
- params->users_max--;
- }
+ if (!IsDigit(*args)) goto fail;
+
+ params->users_max = atoi(args);
+ if (params->users_max == 0)
+ params->users_max = INT_MAX;
+ else
+ params->users_max--;
}
else if (*args == '>')
{
args++;
if (IsDigit(*args))
params->users_min = atoi(args) + 1;
- else
+ else if (args[0] == '-' && IsDigit(args[1]))
params->users_min = 0;
+ else
+ goto fail;
}
else if (*args == 'C' || *args == 'c')
{
{
/* Creation time earlier than last x minutes. */
args++;
- if (IsDigit(*args))
- {
- params->created_max = rb_current_time() - (60 * atoi(args));
- }
+ if (!IsDigit(*args)) goto fail;
+ params->created_max = rb_current_time() - (60 * atoi(args));
}
else if (*args == '<')
{
/* Creation time within last x minutes. */
args++;
- if (IsDigit(*args))
- {
- params->created_min = rb_current_time() - (60 * atoi(args));
- }
+ if (!IsDigit(*args)) goto fail;
+ params->created_min = rb_current_time() - (60 * atoi(args));
+ }
+ else
+ {
+ goto fail;
}
}
else if (*args == 'T' || *args == 't')
{
/* Topic change time earlier than last x minutes. */
args++;
- if (IsDigit(*args))
- {
- params->topic_max = rb_current_time() - (60 * atoi(args));
- }
+ if (!IsDigit(*args)) goto fail;
+ params->topic_max = rb_current_time() - (60 * atoi(args));
}
else if (*args == '<')
{
/* Topic change time within last x minutes. */
args++;
- if (IsDigit(*args))
- {
- params->topic_min = rb_current_time() - (60 * atoi(args));
- }
+ if (!IsDigit(*args)) goto fail;
+ params->topic_min = rb_current_time() - (60 * atoi(args));
+ }
+ else
+ {
+ goto fail;
}
}
else if (*args == '!')
rb_free(params->mask);
params->mask = rb_strdup(args);
}
+ else
+ {
+ goto fail;
+ }
if (EmptyString(p))
break;
}
safelist_client_instantiate(source_p, params);
+ return;
+
+fail:
+ rb_free(params);
+ sendto_one(source_p, form_str(RPL_LISTSTART), me.name, source_p->name);
+ sendto_one_notice(source_p, ":Invalid parameters for /LIST");
+ sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
}
/*
*/
static void safelist_client_instantiate(struct Client *client_p, struct ListClient *params)
{
+ struct Channel *chptr;
+
s_assert(MyClient(client_p));
s_assert(params != NULL);
rb_dlinkAddAlloc(client_p, &safelisting_clients);
/* give the user some initial data to work with */
+ if (params->mask && (chptr = find_channel(params->mask)))
+ {
+ bool visible = !SecretChannel(chptr) || IsMember(client_p, chptr);
+ if (visible || params->operspy)
+ list_one_channel(client_p, chptr, visible);
+ }
safelist_iterate_client(client_p);
}
if (params->created_max && chptr->channelts > params->created_max)
return;
- if (params->mask && !match(params->mask, chptr->chname))
+ if (params->mask && (!irccmp(params->mask, chptr->chname) || !match(params->mask, chptr->chname)))
return;
if (params->nomask && match(params->nomask, chptr->chname))