dh-gex: Check return value of ssh_get_random()

CID #1422162

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Andreas Schneider
2020-04-02 07:25:53 +02:00
parent a9a7c2dc29
commit d2f0d3270a

View File

@@ -366,8 +366,13 @@ static bool dhgroup_better_size(uint32_t pmin,
*/
static bool invn_chance(int n)
{
uint32_t nounce;
ssh_get_random(&nounce, sizeof(nounce), 0);
uint32_t nounce = 0;
int ok;
ok = ssh_get_random(&nounce, sizeof(nounce), 0);
if (!ok) {
return false;
}
return (nounce % n) == 0;
}