HomeFreeBSD

SHA2Init() should use signed assertions when checking an enum

Description

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 <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

Details

Provenance
Richard Yao <richard.yao@alumni.stonybrook.edu>Authored on Mar 4 2023, 8:53 PM
Brian Behlendorf <behlendorf1@llnl.gov>Committed on Mar 6 2023, 11:26 PM
Parents
rG47119d60eff6: Restore ASMABI and other Unify work
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rG8846139b45ff: SHA2Init() should use signed assertions when checking an enum (authored by Richard Yao <richard.yao@alumni.stonybrook.edu>).Mar 6 2023, 11:26 PM