Fix to make sure wc_RNG_GenerateBlock return code is checked in test.h GetRandomPort.

This commit is contained in:
David Garske
2018-09-18 12:55:52 -07:00
parent 9e305a01b4
commit 4981480215

View File

@@ -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));
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 */