SHA2Init() should use signed assertions when checking an enum
The recent 4c5fec01a4
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 <milky-zfs@mcmilk.de>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reported-by: Coverity (CID-1535300)
Closes #14573
This commit is contained in:
parent
47119d60ef
commit
8846139b45
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue