Fix 'stroke loglevel any'
authorTobias Brunner <tobias@strongswan.org>
Wed, 13 Feb 2013 11:11:37 +0000 (12:11 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 13 Feb 2013 11:18:20 +0000 (12:18 +0100)
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'.

src/libcharon/plugins/stroke/stroke_socket.c

index 2771f01..e31616c 100644 (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);
 }