From d2f0d3270a8733e3e8ad3788e8a315c533c765f9 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 2 Apr 2020 07:25:53 +0200 Subject: [PATCH] dh-gex: Check return value of ssh_get_random() CID #1422162 Signed-off-by: Andreas Schneider Reviewed-by: Jakub Jelen --- src/dh-gex.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/dh-gex.c b/src/dh-gex.c index 6c75c69e..9bf0546a 100644 --- a/src/dh-gex.c +++ b/src/dh-gex.c @@ -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; }