]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
charon-tkm: Check for error when acquiring ESA ID
authorAdrian-Ken Rueegsegger <ken@codelabs.ch>
Mon, 4 Sep 2017 13:00:42 +0000 (15:00 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 15 Sep 2017 10:16:57 +0000 (12:16 +0200)
src/charon-tkm/src/tkm/tkm_kernel_ipsec.c

index 5decde92be021be3c008fdcb3947512dec26a441..87b516d4396e626b3b0a329991ec604a6ea8bfe1 100644 (file)
@@ -134,6 +134,12 @@ METHOD(kernel_ipsec_t, add_sa, status_t,
        }
 
        esa_id = tkm->idmgr->acquire_id(tkm->idmgr, TKM_CTX_ESA);
+       if (esa_id == 0)
+       {
+               DBG1(DBG_KNL, "unable to acquire esa context id");
+               goto esa_id_failure;
+       }
+
        if (!tkm->sad->insert(tkm->sad, esa_id, data->reqid, local, peer,
                                                  spi_loc, spi_rem, id->proto))
        {
@@ -196,6 +202,7 @@ failure:
        tkm->sad->remove(tkm->sad, esa_id);
 sad_failure:
        tkm->idmgr->release_id(tkm->idmgr, TKM_CTX_ESA, esa_id);
+esa_id_failure:
        chunk_free(&esa.nonce_i);
        chunk_free(&esa.nonce_r);
        return FAILED;