Skip to content
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

UnlockedFlash::program can write out of bounds #546

Open
sjorsdewit opened this issue Oct 25, 2022 · 0 comments
Open

UnlockedFlash::program can write out of bounds #546

sjorsdewit opened this issue Oct 25, 2022 · 0 comments

Comments

@sjorsdewit
Copy link

It seems the function UnlockedFlash::program() can write outside the bounds of the flash memory if given an invalid offset:

stm32f4xx-hal/src/flash.rs

Lines 239 to 241 in 6d0c292

unsafe {
ptr::write_volatile(ptr.add(offset), *byte);
}

One way to improve this might be to check offset against self.len() each iteration, or maybe there is a way to pre-compute if the offset + length of the iterator exceeds the flash length?

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

No branches or pull requests

1 participant