Coverity fixes for new fwtpm code#483
Merged
aidangarske merged 1 commit intowolfSSL:masterfrom Apr 17, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Addresses Coverity CID 909315 by tightening bounds checks and handling return values in the new fwTPM code paths.
Changes:
- Silence/handle flagged unchecked return values (e.g.,
remove, hashing APIs). - Adjust buffer size limits to safer constants and add additional size guards.
- Improve CLI example robustness by validating hex parsing results.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| tests/fwtpm_unit_tests.c | Explicitly ignores remove() return to satisfy static analysis in tests. |
| src/fwtpm/fwtpm_main.c | Explicitly ignores remove() return when --clear is used. |
| src/fwtpm/fwtpm_command.c | Adds bounds checks and some crypto API return checking in several TPM command handlers. |
| examples/pcr/policy.c | Adds error handling for hexToByte() conversion failures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
aidangarske
reviewed
Apr 17, 2026
Member
aidangarske
left a comment
There was a problem hiding this comment.
Skoll Code Review
Scan type: review-security
Overall recommendation: REQUEST_CHANGES
Findings: 4 total — 1 posted, 3 skipped
Posted findings
- [High] Buffer overflow regression: sensDataSize check weakened for NO_RSA builds in FwCmd_Create/FwCmd_CreateLoaded —
src/fwtpm/fwtpm_command.c:3590,5462,5499
Skipped findings
- [Low]
Odd-length hex digest silently reinterpreted after hexToByte fix in policy.c - [Info]
FwCmd_Quote: wc_HashFree is intentionally skipped on wc_HashInit failure — matches existing pattern - [Info]
FwCmd_StartAuthSession bindAuth.size clamp — analysis confirms existing callers cannot exceed the buffer
Review generated by Skoll
71545b6 to
34ae62e
Compare
aidangarske
approved these changes
Apr 17, 2026
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.
Coverity Fixes (CID 909296–909315)
Address 18 Coverity findings: 4 bug fixes, 2 dead code cleanups, 5 defense-in-depth improvements, and 7 reviewed-no-action.
Bug Fixes
src/fwtpm/fwtpm_command.csensDatabuffer size check used the wrong constant (FWTPM_MAX_PRIVKEY_DER= 1280 vs. actual buffer sizeFWTPM_MAX_DATA_BUF= 1024). Corrected inFwCmd_CreateandFwCmd_CreateLoaded(3 locations). Defense-in-depth — upstream parser already bounds the size.src/fwtpm/fwtpm_command.cwc_Hash()inFwCmd_NV_Certify.src/fwtpm/fwtpm_command.cwc_HashInit()inFwCmd_Quoteand guarded subsequent hash operations.examples/pcr/policy.chexToByte()returnsint(may be -1) was assigned directly toword32. Added error check with early return.Dead Code Cleanup
src/fwtpm/fwtpm_command.ccmdPkt.posassignment inFWTPM_ProcessCommand(overwritten before use).src/fwtpm/fwtpm_command.cFwCmd_LoadExternalSYMCIPHER path to match the actualqSzconstraint (FWTPM_MAX_DER_SIG_BUF).Defense-in-Depth
src/fwtpm/fwtpm_main.c,tests/fwtpm_unit_tests.cremove()to(void)— failure is intentional (file may not exist).src/fwtpm/fwtpm_command.cFwCmd_MakeCredentialto use the actual buffer size (FWTPM_MAX_PUB_BUF).src/fwtpm/fwtpm_command.ccredSzafterFwCredentialUnwrap()inFwCmd_ActivateCredential.src/fwtpm/fwtpm_command.cbindAuth.sizeclamp inFwCmd_StartAuthSession.Reviewed – No Action Required
7 additional findings (CID 909296, 909297, 909298, 909300, 909308, 909309, 909311) were reviewed and determined to be false positives or by-design behavior; no code changes required.