From 8846139b45ff2ddd416f1a8b6227862e519898fc Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Sat, 4 Mar 2023 15:53:58 -0500 Subject: SHA2Init() should use signed assertions when checking an enum The recent 4c5fec01a48acc184614ab8735e6954961990235 commit caused Coverity to report that ASSERT3U(algotype, >=, SHA256_MECH_INFO_TYPE); is always true. That is because the signed algotype and signed SHA256_MECH_INFO_TYPE values were cast to unsigned types. To fix this, we switch the assertions to use ASSERT3S(), which retains the signedness of the original values for the comparison. Reviewed-by: Tino Reichardt Reviewed-by: Alexander Motin Signed-off-by: Richard Yao Reported-by: Coverity (CID-1535300) Closes #14573 --- module/icp/algs/sha2/sha2_generic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module') diff --git a/module/icp/algs/sha2/sha2_generic.c b/module/icp/algs/sha2/sha2_generic.c index e69dc7771..60d7ad9a1 100644 --- a/module/icp/algs/sha2/sha2_generic.c +++ b/module/icp/algs/sha2/sha2_generic.c @@ -400,8 +400,8 @@ SHA2Init(int algotype, SHA2_CTX *ctx) sha256_ctx *ctx256 = &ctx->sha256; sha512_ctx *ctx512 = &ctx->sha512; - ASSERT3U(algotype, >=, SHA256_MECH_INFO_TYPE); - ASSERT3U(algotype, <=, SHA512_256_MECH_INFO_TYPE); + ASSERT3S(algotype, >=, SHA256_MECH_INFO_TYPE); + ASSERT3S(algotype, <=, SHA512_256_MECH_INFO_TYPE); memset(ctx, 0, sizeof (*ctx)); ctx->algotype = algotype; -- cgit v1.2.3