Fix 'stroke loglevel any'

Before b46a5cd4 this worked if debug_t was unsigned.  In that case -1,
as returned by enum_from_name(), would result in a large positive number.
So any unknown debug group (including 'any') had the same effect that
was only intended for 'any'.
This commit is contained in:
Tobias Brunner 2013-02-13 12:11:37 +01:00
parent 5374fe3a09
commit 96a2d2077b

View file

@ -516,11 +516,18 @@ static void stroke_loglevel(private_stroke_socket_t *this,
DBG1(DBG_CFG, "received stroke: loglevel %d for %s",
msg->loglevel.level, msg->loglevel.type);
group = enum_from_name(debug_names, msg->loglevel.type);
if ((int)group < 0)
if (strcaseeq(msg->loglevel.type, "any"))
{
fprintf(out, "invalid type (%s)!\n", msg->loglevel.type);
return;
group = DBG_ANY;
}
else
{
group = enum_from_name(debug_names, msg->loglevel.type);
if ((int)group < 0)
{
fprintf(out, "invalid type (%s)!\n", msg->loglevel.type);
return;
}
}
charon->set_level(charon, group, msg->loglevel.level);
}