F-9749: propagate the verify result from wolfBoot_start to the exit code

wolfBoot_start() in hal/library.c ended its exit: path with an
unconditional 'return 0;', so a rejected image (bad header, hash or
signature) still made the test-lib process exit 0. main() propagates
wolfBoot_start()'s return value, so the failure was only visible in
the printed "Failure" message, which the test-library workflow had to
grep for (TODO referencing PR #625).

Return ret, which carries the wolfBoot_verify_*() error on every path
that reaches exit: with a failure. The success path never returns:
do_boot() jumps to the firmware.

The test-library workflow drops the status-rewriting workaround and
asserts the non-zero exit code directly, keeping the "Failure"
message check as a diagnostic.

Verification:
- Built: make test-lib (host, library.config, ED25519/SHA256).
- Tested: local repro of the workflow flow: corrupt the last byte of
  a signed image; before the fix the process exited 0 while printing
  "Failure -1", after the fix it exits 255; a valid image still
  exits 0 with "Firmware Valid".
- Pitfalls: 'return ret' only changes the error paths; do_boot() does
  not return on success.
- Style: the cstyle-check.sh FMT flag on hal/library.c is present on
  the pre-change file as well (not introduced here).
- Message: F-9749: prefix, no co-author trailers.
pull/870/head
Daniele Lacamera 2026-08-24 18:00:54 +02:00
parent c9fcdddefb
commit 2e918de239
2 changed files with 5 additions and 11 deletions

View File

@ -174,16 +174,8 @@ jobs:
echo "$output"
# TODO hal/library.c does not currently return an error code during failure
# Test only looks for the word "Failure"
# See https://github.com/wolfSSL/wolfBoot/pull/625
# If the tool printed "Failure", treat it as a failure regardless of exit code
if echo "$output" | grep -F "Failure" >/dev/null; then
status=1
fi
# Must have failed (non-zero exit)
# A rejected image must exit non-zero: wolfBoot_start() propagates
# the verify error to the process exit code
if [ "$status" -eq 0 ]; then
echo "Expected failure, but exit code was 0"
exit 1

View File

@ -165,7 +165,9 @@ int wolfBoot_start(void)
(int)os_image.signature_ok);
}
return 0;
/* The error paths reach this point with ret < 0; propagate it so a
* rejected image does not look like a successful boot to the caller. */
return ret;
}