Skip to contentSkip to conversation

kunit/fortify: Fix memcmp() test to be amplitude agnostic

PATCH New Kees Cook 1 participant 1 message May 18, 2024 Library code

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 kunit/fortify: Fix memcmp() test to be amplitude agnostic

When memcmp() returns a non-zero value, only the signed bit has any meaning. The actual value may differ between implementations.

---
Cc: [email protected]

---
 lib/fortify_kunit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/fortify_kunit.c +1 -1
index d2377e00caab..39da5b3bc649 100644
@@ -990,7 +990,7 @@ static void fortify_test_memcmp(struct kunit *test)
 	KUNIT_ASSERT_EQ(test, memcmp(one, two, one_len), 0);
 	KUNIT_EXPECT_EQ(test, fortify_read_overflows, 0);
 	/* Still in bounds, but no longer matching. */
-	KUNIT_ASSERT_EQ(test, memcmp(one, two, one_len + 1), -32);
+	KUNIT_ASSERT_LT(test, memcmp(one, two, one_len + 1), 0);
 	KUNIT_EXPECT_EQ(test, fortify_read_overflows, 0);
 
 	/* Catch too-large ranges. */
Signature · 1 line
2.34.1