Fix 4 Coverity findings (fwTPM PolicyNV, listen socket, secret_seal)#542
Open
aidangarske wants to merge 1 commit into
Open
Fix 4 Coverity findings (fwTPM PolicyNV, listen socket, secret_seal)#542aidangarske wants to merge 1 commit into
aidangarske wants to merge 1 commit into
Conversation
…tsockopt, secret_seal hex/policy)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes four genuine Coverity findings from the latest scan. The remaining 19 outstanding CIDs were reviewed and dismissed as false positives (config-dependent dead-branch templates, and TPM/file values already bounded or MAC-authenticated before use).
Fixes
FwCmd_PolicyNV(src/fwtpm/fwtpm_command.c) — logically dead error-cleanup. Theif (hashCtxInit) wc_HashFree(...)block was unreachable because the intermediatewc_HashUpdate/wc_HashFinalreturn codes were ignored, sorccould never become non-zero between init and the inline free. Now every hash return is checked and the free is deferred on failure, making the bottom cleanup live and closing the unchecked-return gap.CreateListenSocket(src/fwtpm/fwtpm_io.c) — uncheckedsetsockopt(SO_REUSEADDR)return. Checked with a non-fatalDEBUG_WOLFTPM-gated diagnostic (the option is advisory).TPM2_Boot_SecretSeal_Example(examples/boot/secret_seal.c) — improper use of negative value.hexToByte()returns-1on malformed hex, which wrapped intoword32 secretSzas0xFFFFFFFF; thesecretSz <= 0guard could not catch it, leading to an over-read. Now captured in anintand rejected when negative.TPM2_Boot_SecretSeal_Example(examples/boot/secret_seal.c) — logically dead code.policyFiledefaulted to"policyauth.bin", so the-publickey=branch (a documented README example) was unreachable. Default is nowNULL, matching thepublicKeyFilesibling, so all branches are reachable.Testing
All three modified files pass
gcc -fsyntax-only.