mirror of
https://github.com/trussed-dev/littlefs2.git
synced 2026-06-20 04:16:32 -07:00
Fixed offset calculation overflowing on large SD cards
This commit is contained in:
+3
-1
@@ -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
|
||||
|
||||
|
||||
@@ -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))
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user