Fix crash if the initiator has no suitable proposal available
authorTobias Brunner <tobias@strongswan.org>
Fri, 26 Apr 2013 13:36:42 +0000 (15:36 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 21 Jun 2013 09:09:03 +0000 (11:09 +0200)
Could be triggered with a typo in the ike or esp options when ! is used.

src/libcharon/encoding/payloads/sa_payload.c

index a588d4e..6134120 100644 (file)
@@ -560,6 +560,11 @@ sa_payload_t *sa_payload_create_from_proposals_v1(linked_list_t *proposals,
 
        this = (private_sa_payload_t*)sa_payload_create(SECURITY_ASSOCIATION_V1);
 
+       if (!proposals || !proposals->get_count(proposals))
+       {
+               return &this->public;
+       }
+
        /* IKEv1 encodes multiple proposals in a single substructure
         * TODO-IKEv1: Encode ESP+AH proposals in two substructs with same num */
        substruct = proposal_substructure_create_from_proposals_v1(proposals,