Check rng return value when generating nonces in libpts

This commit is contained in:
Tobias Brunner
2012-07-16 14:53:36 +02:00
committed by Martin Willi
parent 10b6ca5fb2
commit cfd824ccde
+6 -2
View File
@@ -226,9 +226,13 @@ METHOD(pts_t, create_dh_nonce, bool,
DBG2(DBG_PTS, "nonce length is %d", nonce_len); DBG2(DBG_PTS, "nonce length is %d", nonce_len);
nonce = this->is_imc ? &this->responder_nonce : &this->initiator_nonce; nonce = this->is_imc ? &this->responder_nonce : &this->initiator_nonce;
chunk_free(nonce); chunk_free(nonce);
rng->allocate_bytes(rng, nonce_len, nonce); if (!rng->allocate_bytes(rng, nonce_len, nonce))
{
DBG1(DBG_PTS, "failed to allocate nonce");
rng->destroy(rng);
return FALSE;
}
rng->destroy(rng); rng->destroy(rng);
return TRUE; return TRUE;
} }