]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Use ref_get() to make sure IKE_SA unique IDs are unique
authorMartin Willi <martin@revosec.ch>
Thu, 9 May 2013 14:39:12 +0000 (16:39 +0200)
committerMartin Willi <martin@revosec.ch>
Thu, 9 May 2013 14:39:12 +0000 (16:39 +0200)
issue-id: 58075c11

src/libcharon/sa/ike_sa.c

index 4f21d4c9bd68249b3cf82069269668b2cbbe804c..e25191782ed43011047ab4ffd54e15537865c3ea 100644 (file)
@@ -2169,7 +2169,7 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id, bool initiator,
                                                 ike_version_t version)
 {
        private_ike_sa_t *this;
-       static u_int32_t unique_id = 0;
+       static refcount_t unique_id = 0;
 
        if (version == IKE_ANY)
        {       /* prefer IKEv2 if protocol not specified */
@@ -2281,8 +2281,7 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id, bool initiator,
                .other_auth = auth_cfg_create(),
                .my_auths = linked_list_create(),
                .other_auths = linked_list_create(),
-               /* BUG: static variable unique_id gets accessed non-atomic */
-               .unique_id = ++unique_id,
+               .unique_id = ref_get(&unique_id),
                .peer_addresses = linked_list_create(),
                .my_vips = linked_list_create(),
                .other_vips = linked_list_create(),