Skip to content

Fix undefined behavior #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 3, 2023
Merged

Fix undefined behavior #19

merged 5 commits into from
Jul 3, 2023

Conversation

alrvid
Copy link
Contributor

@alrvid alrvid commented Jun 30, 2023

Fixes undefined behavior where SDCardBlockDevice::wait_for_completition() runs off the end without returning a value.

alrvid added 5 commits June 30, 2023 17:42
Fixes undefined behavior where SDCardBlockDevice::wait_for_completition() runs off the end without returning a value.
The size of large block devices overflows when these variables are 32 bits long. For example, a 32 GB SD Card is reported as smaller than it really is.
The sd_card_info.sector_count and sd_card_info.sector_size_bytes variables are both 32 bit, so the multiplication overflows for large block devices.
@alrvid
Copy link
Contributor Author

alrvid commented Jun 30, 2023

Also fixes an overflow in the reported size of block devices by changing the data type to 64 bits and by preventing a multiplication overflow.

@facchinm facchinm merged commit 74f57cc into arduino:main Jul 3, 2023
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