Skip to content

sbchooser: fix load_secdb_from_file returning fd instead of rc#302

Merged
vathpela merged 1 commit intorhboot:mainfrom
adsuna:fix-sbchooser-return-fd
Apr 21, 2026
Merged

sbchooser: fix load_secdb_from_file returning fd instead of rc#302
vathpela merged 1 commit intorhboot:mainfrom
adsuna:fix-sbchooser-return-fd

Conversation

@adsuna
Copy link
Copy Markdown
Contributor

@adsuna adsuna commented Apr 21, 2026

When read_file() fails, returning fd instead of rc causes callers to miss the error since fd is a non-negative integer after close(). Fix by returning rc.
This affects when an invalid path is passed as db where the output shows not trusted rather than a read error.

# bugged output
LD_LIBRARY_PATH=src src/sbchooser --explain -d /tmp -i tests/shim-16.1-4.el10.x64.msft2023.efi -i tests/shim-16.1-4.el10.x64.msft2011.efi; echo "exit code: $?"
tests/shim-16.1-4.el10.x64.msft2023.efi is not trusted because no certs or hashes trust it
tests/shim-16.1-4.el10.x64.msft2011.efi is not trusted because no certs or hashes trust it
exit code: 0

# expected output
LD_LIBRARY_PATH=src src/sbchooser --explain -d /tmp -i tests/shim-16.1-4.el10.x64.msft2023.efi -i tests/shim-16.1-4.el10.x64.msft2011.efi; echo "exit code: $?"
sbchooser: Could not load db from "/tmp": Is a directory
exit code: 2

When read_file() fails, returning fd instead of rc causes callers to
miss the error since fd is a non-negative integer after close(). Fix
by returning rc.

Signed-off-by: Aditya Nair <adnair@redhat.com>
@vathpela vathpela merged commit d7f5527 into rhboot:main Apr 21, 2026
6 checks passed
@adsuna adsuna deleted the fix-sbchooser-return-fd branch April 22, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants