From f07a9f80fb6f3099d75534c1e64f448d4b397931 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 14 May 2026 22:20:02 +0200 Subject: Fix minor errors in the test and check that we are not writing out of bounds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- librecrypt_rng_.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'librecrypt_rng_.c') diff --git a/librecrypt_rng_.c b/librecrypt_rng_.c index e620c6f..4c6d5dc 100644 --- a/librecrypt_rng_.c +++ b/librecrypt_rng_.c @@ -374,18 +374,24 @@ main(void) #define CHECK1()\ do {\ + CANARY_FILL(buf1);\ n1 = librecrypt_rng_(buf1, sizeof(buf1), NULL);\ EXPECT(n1 >= 128 && (size_t)n1 <= sizeof(buf1));\ EXPECT(memcmp(buf1, buf2, (size_t)MIN(n1, n2)));\ + CANARY_CHECK(buf1, (size_t)n1);\ } while (0) #define CHECK2()\ do {\ + CANARY_FILL(buf1);\ + CANARY_FILL(buf2);\ n1 = librecrypt_rng_(buf1, sizeof(buf1), NULL);\ n2 = librecrypt_rng_(buf2, sizeof(buf2), &user);\ EXPECT(n1 >= 128 && (size_t)n1 <= sizeof(buf1));\ EXPECT(n2 >= 128 && (size_t)n2 <= sizeof(buf2));\ EXPECT(memcmp(buf1, buf2, (size_t)MIN(n1, n2)));\ + CANARY_CHECK(buf1, (size_t)n1);\ + CANARY_CHECK(buf2, (size_t)n2);\ } while (0) /* Test with output pattern (useful for other tests) */ -- cgit v1.2.3-70-g09d2