Fix error handling in wolfTPM examples - #598
Merged
Merged
Conversation
aidangarske
commented
Sep 9, 2026
Member
There was a problem hiding this comment.
🟡 Changes recommended
There are a few correctness/debuggability gaps in the updated error handling (including a potential UINT64 wrap in clock_set.c) that should be addressed before merge.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR tightens error handling and correctness in several wolfTPM example programs, reducing “silent success/failure” cases and avoiding insecure example behavior (notably certificate verification override).
Changes:
- TLS verify callback now honors
preverifyinstead of always overriding certificate failures. - Example utilities improve file I/O error handling (open/write/read) and propagate failures via
rc/goto exit. - Timestamp and PCR examples adjust time/digest handling for more correct behavior across build configurations.
File summaries
| File | Description |
|---|---|
| examples/tls/tls_common.h | Stop overriding certificate verification failures; return preverify. |
| examples/timestamp/clock_set.c | Treat CLI argument as a forward increment (adds to current clock). |
| examples/pkcs7/pkcs7.c | Fail fast on output file open failure in two code paths. |
| examples/pcr/quote.c | Add explicit open/write failure handling when saving quote output. |
| examples/pcr/extend.c | Improve file read loop error handling; add “digest-from-file” path when wolfCrypt is disabled. |
| examples/attestation/make_credential.c | Check wolfTPM2_GetRandom result; harden file write handling for output blob/secret. |
Review details
Suppressed comments (1)
examples/pkcs7/pkcs7.c:314
- On file open failure, this now returns -1 but doesn't print any error, which makes it hard to diagnose why the example failed. Emit a message that includes the output path before exiting.
else {
rc = -1; goto exit;
}
- Files reviewed: 6/6 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
aidangarske
force-pushed
the
examples-fixes-11902
branch
from
September 9, 2026 16:24
bbae5ed to
0820b30
Compare
aidangarske
marked this pull request as ready for review
September 9, 2026 16:28
aidangarske
force-pushed
the
examples-fixes-11902
branch
from
September 9, 2026 17:43
0820b30 to
bfda30f
Compare
dgarske
reviewed
Sep 9, 2026
dgarske
previously approved these changes
Sep 9, 2026
aidangarske
force-pushed
the
examples-fixes-11902
branch
from
September 9, 2026 22:31
bfda30f to
2f4b959
Compare
dgarske
previously approved these changes
Sep 9, 2026
dgarske
self-requested a review
September 10, 2026 16:34
dgarske
approved these changes
Sep 10, 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.