Skip to content

Fix offset calculation overflowing on large storage devices#124

Merged
robin-nitrokey merged 1 commit intotrussed-dev:mainfrom
HelloWorldTeraByte:fix/offset-calc-overflow-on-large-sd-cards
Mar 4, 2026
Merged

Fix offset calculation overflowing on large storage devices#124
robin-nitrokey merged 1 commit intotrussed-dev:mainfrom
HelloWorldTeraByte:fix/offset-calc-overflow-on-large-sd-cards

Conversation

@HelloWorldTeraByte
Copy link

This PR fixes offset calculation overflowing on large storage devices.

The overflow can happen on the lfs_config_read and lfs_config_prog C callback functions.
The overflow does not happen on other two low level C callback functions as it already uses usize.

I decided to use usize instead of u64 as Storage driver accepts a usize. So the overflow can still happen on 32 bit systems for large storage devices.

Please let me know if you want to handle the overflow more gracefully with error codes as well, I would be more than happy to update it.

@robin-nitrokey
Copy link
Member

Good catch, thank you! Let’s merge this as-is and implement the error handling separately, see #125.

@robin-nitrokey robin-nitrokey force-pushed the fix/offset-calc-overflow-on-large-sd-cards branch from 83b6db1 to f31f4dc Compare March 4, 2026 08:34
@robin-nitrokey robin-nitrokey added skip-publish-check Skip the check that tests publishing to crates.io for this PR labels Mar 4, 2026
@robin-nitrokey robin-nitrokey merged commit f31f4dc into trussed-dev:main Mar 4, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-publish-check Skip the check that tests publishing to crates.io for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants