encoding: Allow ke_payload_create_from_diffie_hellman() to fail
[strongswan.git] / src / libcharon / sa / ikev1 / phase1.c
index d01a831..a81fa58 100644 (file)
@@ -694,7 +694,13 @@ METHOD(phase1_t, add_nonce_ke, bool,
        nonce_gen_t *nonceg;
        chunk_t nonce;
 
-       ke_payload = ke_payload_create_from_diffie_hellman(PLV1_KEY_EXCHANGE, this->dh);
+       ke_payload = ke_payload_create_from_diffie_hellman(PLV1_KEY_EXCHANGE,
+                                                                                                          this->dh);
+       if (!ke_payload)
+       {
+               DBG1(DBG_IKE, "creating KE payload failed");
+               return FALSE;
+       }
        message->add_payload(message, &ke_payload->payload_interface);
 
        nonceg = this->keymat->keymat.create_nonce_gen(&this->keymat->keymat);