Fixed crash and locking issues while unrouting connections via stroke
authorMartin Willi <martin@revosec.ch>
Tue, 13 Mar 2012 09:55:58 +0000 (10:55 +0100)
committerMartin Willi <martin@revosec.ch>
Tue, 13 Mar 2012 09:56:22 +0000 (10:56 +0100)
src/libcharon/plugins/stroke/stroke_control.c

index f0d8f3b..729e9d7 100644 (file)
@@ -633,8 +633,7 @@ METHOD(stroke_control_t, unroute, void,
 {
        child_sa_t *child_sa;
        enumerator_t *enumerator;
-       u_int32_t id;
-       bool found = FALSE;
+       u_int32_t id = 0;
 
        if (charon->shunts->uninstall(charon->shunts, msg->unroute.name))
        {
@@ -648,15 +647,17 @@ METHOD(stroke_control_t, unroute, void,
                if (streq(msg->unroute.name, child_sa->get_name(child_sa)))
                {
                        id = child_sa->get_reqid(child_sa);
-                       enumerator->destroy(enumerator);
-                       charon->traps->uninstall(charon->traps, id);
-                       fprintf(out, "configuration '%s' unrouted\n", msg->unroute.name);
-                       found = TRUE;
+                       break;
                }
        }
        enumerator->destroy(enumerator);
 
-       if (!found)
+       if (id)
+       {
+               charon->traps->uninstall(charon->traps, id);
+               fprintf(out, "configuration '%s' unrouted\n", msg->unroute.name);
+       }
+       else
        {
                fprintf(out, "configuration '%s' not found\n", msg->unroute.name);
        }