Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

-
### Fixed

- Fixed offset calculation overflow in `lfs_config_read` and `lfs_config_prog` if the offset is larger than `u32::MAX`.

## [v0.6.1](https://github.com/trussed-dev/littlefs2/releases/tag/0.6.1) - 2025-03-04

Expand Down
9 changes: 5 additions & 4 deletions src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,9 @@ impl<Storage: driver::Storage> Filesystem<'_, Storage> {
// println!("in lfs_config_read for {} bytes", size);
let storage = unsafe { &mut *((*c).context as *mut Storage) };
debug_assert!(!c.is_null());
let block_size = unsafe { c.read().block_size };
let off = (block * block_size + off) as usize;
// let block_size = unsafe { c.read().block_size };
let block_size = Storage::BLOCK_SIZE;
let off = block as usize * block_size + off as usize;
let buf: &mut [u8] = unsafe { slice::from_raw_parts_mut(buffer as *mut u8, size as usize) };

error_code_from(storage.read(off, buf))
Expand All @@ -556,8 +557,8 @@ impl<Storage: driver::Storage> Filesystem<'_, Storage> {
let storage = unsafe { &mut *((*c).context as *mut Storage) };
debug_assert!(!c.is_null());
// let block_size = unsafe { c.read().block_size };
let block_size = Storage::BLOCK_SIZE as u32;
let off = (block * block_size + off) as usize;
let block_size = Storage::BLOCK_SIZE;
let off = block as usize * block_size + off as usize;
let buf: &[u8] = unsafe { slice::from_raw_parts(buffer as *const u8, size as usize) };

error_code_from(storage.write(off, buf))
Expand Down
Loading