me = this->ike_sa->get_my_host(this->ike_sa);
other = this->ike_sa->get_other_host(this->ike_sa);
- message = message_create(IKEV1_MAJOR_VERSION, IKEV1_MINOR_VERSION);
if (new_mid)
{
- this->rng->get_bytes(this->rng, sizeof(this->initiating.mid),
- (void*)&this->initiating.mid);
+ if (!this->rng->get_bytes(this->rng, sizeof(this->initiating.mid),
+ (void*)&this->initiating.mid))
+ {
+ DBG1(DBG_IKE, "failed to allocate message ID, destroying IKE_SA");
+ flush(this);
+ return DESTROY_ME;
+ }
}
+ message = message_create(IKEV1_MAJOR_VERSION, IKEV1_MINOR_VERSION);
message->set_message_id(message, this->initiating.mid);
message->set_source(message, me->clone(me));
message->set_destination(message, other->clone(other));
DBG1(DBG_IKE, "ignore malformed INFORMATIONAL request");
return;
}
-
+ if (!this->rng->get_bytes(this->rng, sizeof(mid), (void*)&mid))
+ {
+ DBG1(DBG_IKE, "failed to allocate message ID");
+ return;
+ }
response = message_create(IKEV1_MAJOR_VERSION, IKEV1_MINOR_VERSION);
response->set_exchange_type(response, INFORMATIONAL_V1);
response->set_request(response, TRUE);
- this->rng->get_bytes(this->rng, sizeof(mid), (void*)&mid);
response->set_message_id(response, mid);
response->add_payload(response, (payload_t*)
notify_payload_create_from_protocol_and_type(NOTIFY_V1,
destroy(this);
return NULL;
}
-
- this->rng->get_bytes(this->rng, sizeof(this->dpd_send),
- (void*)&this->dpd_send);
+ if (!this->rng->get_bytes(this->rng, sizeof(this->dpd_send),
+ (void*)&this->dpd_send))
+ {
+ DBG1(DBG_IKE, "failed to allocate message ID, unable to create IKE_SA");
+ destroy(this);
+ return NULL;
+ }
this->dpd_send &= 0x7FFFFFFF;
return &this->public;