From 4981480215f8ba3f41a18ecbe86c691b52fb4a72 Mon Sep 17 00:00:00 2001 From: David Garske Date: Tue, 18 Sep 2018 12:55:52 -0700 Subject: [PATCH] Fix to make sure `wc_RNG_GenerateBlock` return code is checked in test.h `GetRandomPort`. --- wolfssl/test.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wolfssl/test.h b/wolfssl/test.h index 926f1f73e..3a540041a 100644 --- a/wolfssl/test.h +++ b/wolfssl/test.h @@ -2970,8 +2970,9 @@ static WC_INLINE word16 GetRandomPort(void) /* Generate random port for testing */ WC_RNG rng; if (wc_InitRng(&rng) == 0) { - wc_RNG_GenerateBlock(&rng, (byte*)&port, sizeof(port)); - port |= 0xC000; /* Make sure its in the 49152 - 65535 range */ + if (wc_RNG_GenerateBlock(&rng, (byte*)&port, sizeof(port)) == 0) { + port |= 0xC000; /* Make sure its in the 49152 - 65535 range */ + } wc_FreeRng(&rng); } (void)rng; /* for WC_NO_RNG case */