From c25ac487af84e71498788577af4ee2e62291e34f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Mon, 18 Dec 2023 10:29:54 +0100 Subject: [PATCH] tests: crypto: rand32: Check return code of sys_csrand_get MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check the return code of sys_csrand_get when testing the function. Ignoring it is bad practice and can also be a security issue if users copy-paste this test code. Signed-off-by: Sebastian Bøe --- tests/crypto/rand32/src/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/crypto/rand32/src/main.c b/tests/crypto/rand32/src/main.c index 1f2492e69e..5436c627cd 100644 --- a/tests/crypto/rand32/src/main.c +++ b/tests/crypto/rand32/src/main.c @@ -90,7 +90,10 @@ ZTEST(rand32_common, test_rand32) printk("Generating bulk fill cryptographically secure random numbers\n"); memset(buf, 0, sizeof(buf)); - sys_csrand_get(buf, sizeof(buf)); + + int err = sys_csrand_get(buf, sizeof(buf)); + + zassert_true(err == 0, "sys_csrand_get returned an error"); for (rnd_cnt = 0; rnd_cnt < (N_VALUES - 1); rnd_cnt++) { gen = buf[rnd_cnt];