Check rng return value when generating fake NAT detection payloads
This commit is contained in:
committed by
Martin Willi
parent
ca9b68eb9e
commit
92f207477c
@@ -123,12 +123,13 @@ static chunk_t generate_natd_hash_faked(private_isakmp_natd_t *this)
|
||||
return chunk_empty;
|
||||
}
|
||||
rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
|
||||
if (!rng)
|
||||
if (!rng ||
|
||||
!rng->allocate_bytes(rng, hasher->get_hash_size(hasher), &chunk))
|
||||
{
|
||||
DBG1(DBG_IKE, "unable to get random bytes for NAT-D fake");
|
||||
DESTROY_IF(rng);
|
||||
return chunk_empty;
|
||||
}
|
||||
rng->allocate_bytes(rng, hasher->get_hash_size(hasher), &chunk);
|
||||
rng->destroy(rng);
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@@ -121,12 +121,12 @@ static chunk_t generate_natd_hash_faked(private_ike_natd_t *this)
|
||||
chunk_t chunk;
|
||||
|
||||
rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK);
|
||||
if (!rng)
|
||||
if (!rng || !rng->allocate_bytes(rng, HASH_SIZE_SHA1, &chunk))
|
||||
{
|
||||
DBG1(DBG_IKE, "unable to get random bytes for NATD fake");
|
||||
DESTROY_IF(rng);
|
||||
return chunk_empty;
|
||||
}
|
||||
rng->allocate_bytes(rng, HASH_SIZE_SHA1, &chunk);
|
||||
rng->destroy(rng);
|
||||
return chunk;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user