m_list: fail on invalid parameters
Loose port of 6ea60b2297948211925e22bd1f284179d680b4ae. I've chosen to reduce indentation where it's convenient, and I'm allowing >-[0-9] as a way of specifying a minimum of 0 because... I don't know, it just seems neater to me.
This commit is contained in:
parent
e7f0aea682
commit
b5bf350512
1 changed files with 37 additions and 25 deletions
|
@ -221,22 +221,23 @@ mo_list(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
|
||||||
if (*args == '<')
|
if (*args == '<')
|
||||||
{
|
{
|
||||||
args++;
|
args++;
|
||||||
if (IsDigit(*args))
|
if (!IsDigit(*args)) goto fail;
|
||||||
{
|
|
||||||
params->users_max = atoi(args);
|
params->users_max = atoi(args);
|
||||||
if (params->users_max == 0)
|
if (params->users_max == 0)
|
||||||
params->users_max = INT_MAX;
|
params->users_max = INT_MAX;
|
||||||
else
|
else
|
||||||
params->users_max--;
|
params->users_max--;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (*args == '>')
|
else if (*args == '>')
|
||||||
{
|
{
|
||||||
args++;
|
args++;
|
||||||
if (IsDigit(*args))
|
if (IsDigit(*args))
|
||||||
params->users_min = atoi(args) + 1;
|
params->users_min = atoi(args) + 1;
|
||||||
else
|
else if (args[0] == '-' && IsDigit(args[1]))
|
||||||
params->users_min = 0;
|
params->users_min = 0;
|
||||||
|
else
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
else if (*args == 'C' || *args == 'c')
|
else if (*args == 'C' || *args == 'c')
|
||||||
{
|
{
|
||||||
|
@ -245,19 +246,19 @@ mo_list(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
|
||||||
{
|
{
|
||||||
/* Creation time earlier than last x minutes. */
|
/* Creation time earlier than last x minutes. */
|
||||||
args++;
|
args++;
|
||||||
if (IsDigit(*args))
|
if (!IsDigit(*args)) goto fail;
|
||||||
{
|
|
||||||
params->created_max = rb_current_time() - (60 * atoi(args));
|
params->created_max = rb_current_time() - (60 * atoi(args));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (*args == '<')
|
else if (*args == '<')
|
||||||
{
|
{
|
||||||
/* Creation time within last x minutes. */
|
/* Creation time within last x minutes. */
|
||||||
args++;
|
args++;
|
||||||
if (IsDigit(*args))
|
if (!IsDigit(*args)) goto fail;
|
||||||
{
|
|
||||||
params->created_min = rb_current_time() - (60 * atoi(args));
|
params->created_min = rb_current_time() - (60 * atoi(args));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (*args == 'T' || *args == 't')
|
else if (*args == 'T' || *args == 't')
|
||||||
|
@ -267,19 +268,19 @@ mo_list(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
|
||||||
{
|
{
|
||||||
/* Topic change time earlier than last x minutes. */
|
/* Topic change time earlier than last x minutes. */
|
||||||
args++;
|
args++;
|
||||||
if (IsDigit(*args))
|
if (!IsDigit(*args)) goto fail;
|
||||||
{
|
|
||||||
params->topic_max = rb_current_time() - (60 * atoi(args));
|
params->topic_max = rb_current_time() - (60 * atoi(args));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (*args == '<')
|
else if (*args == '<')
|
||||||
{
|
{
|
||||||
/* Topic change time within last x minutes. */
|
/* Topic change time within last x minutes. */
|
||||||
args++;
|
args++;
|
||||||
if (IsDigit(*args))
|
if (!IsDigit(*args)) goto fail;
|
||||||
{
|
|
||||||
params->topic_min = rb_current_time() - (60 * atoi(args));
|
params->topic_min = rb_current_time() - (60 * atoi(args));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (*args == '!')
|
else if (*args == '!')
|
||||||
|
@ -293,6 +294,10 @@ mo_list(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
|
||||||
rb_free(params->mask);
|
rb_free(params->mask);
|
||||||
params->mask = rb_strdup(args);
|
params->mask = rb_strdup(args);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
if (EmptyString(p))
|
if (EmptyString(p))
|
||||||
break;
|
break;
|
||||||
|
@ -302,6 +307,13 @@ mo_list(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
|
||||||
}
|
}
|
||||||
|
|
||||||
safelist_client_instantiate(source_p, params);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue