Check rng return value when generating fake NAT detection payloads

This commit is contained in:
Tobias Brunner
2012-07-16 14:53:35 +02:00
committed by Martin Willi
parent ca9b68eb9e
commit 92f207477c
2 changed files with 5 additions and 4 deletions
+3 -2
View File
@@ -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;
}
+2 -2
View File
@@ -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;
}