In stroke counters, check if we have an IKE_SA before getting the name from it
authorMartin Willi <martin@revosec.ch>
Tue, 19 Mar 2013 10:20:35 +0000 (11:20 +0100)
committerMartin Willi <martin@revosec.ch>
Tue, 19 Mar 2013 10:20:35 +0000 (11:20 +0100)
Fixes a segfault when receiving an invalid IKE SPI, where we don't have an
IKE_SA for the raised alert.

src/libcharon/plugins/stroke/stroke_counter.c

index ff4746b..747d51d 100644 (file)
@@ -113,10 +113,13 @@ static char *get_ike_sa_name(ike_sa_t *ike_sa)
 {
        peer_cfg_t *peer_cfg;
 
-       peer_cfg = ike_sa->get_peer_cfg(ike_sa);
-       if (peer_cfg)
+       if (ike_sa)
        {
-               return peer_cfg->get_name(peer_cfg);
+               peer_cfg = ike_sa->get_peer_cfg(ike_sa);
+               if (peer_cfg)
+               {
+                       return peer_cfg->get_name(peer_cfg);
+               }
        }
        return NULL;
 }