receiver: Properly clean up if hasher or RNG can't be created
This commit is contained in:
@@ -656,8 +656,8 @@ METHOD(receiver_t, del_esp_cb, void,
|
|||||||
METHOD(receiver_t, destroy, void,
|
METHOD(receiver_t, destroy, void,
|
||||||
private_receiver_t *this)
|
private_receiver_t *this)
|
||||||
{
|
{
|
||||||
this->rng->destroy(this->rng);
|
DESTROY_IF(this->rng);
|
||||||
this->hasher->destroy(this->hasher);
|
DESTROY_IF(this->hasher);
|
||||||
this->esp_cb_mutex->destroy(this->esp_cb_mutex);
|
this->esp_cb_mutex->destroy(this->esp_cb_mutex);
|
||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
@@ -717,15 +717,14 @@ receiver_t *receiver_create()
|
|||||||
if (!this->hasher)
|
if (!this->hasher)
|
||||||
{
|
{
|
||||||
DBG1(DBG_NET, "creating cookie hasher failed, no hashers supported");
|
DBG1(DBG_NET, "creating cookie hasher failed, no hashers supported");
|
||||||
free(this);
|
destroy(this);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
this->rng = lib->crypto->create_rng(lib->crypto, RNG_STRONG);
|
this->rng = lib->crypto->create_rng(lib->crypto, RNG_STRONG);
|
||||||
if (!this->rng)
|
if (!this->rng)
|
||||||
{
|
{
|
||||||
DBG1(DBG_NET, "creating cookie RNG failed, no RNG supported");
|
DBG1(DBG_NET, "creating cookie RNG failed, no RNG supported");
|
||||||
this->hasher->destroy(this->hasher);
|
destroy(this);
|
||||||
free(this);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!this->rng->get_bytes(this->rng, SECRET_LENGTH, this->secret))
|
if (!this->rng->get_bytes(this->rng, SECRET_LENGTH, this->secret))
|
||||||
|
|||||||
Reference in New Issue
Block a user