Skip to content

Commit

Permalink
fix corruption check
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianPugh committed Aug 17, 2023
1 parent df238eb commit 6de3fc6
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lfs.c
Expand Up @@ -46,8 +46,7 @@ static int lfs_bd_read(lfs_t *lfs,
lfs_block_t block, lfs_off_t off,
void *buffer, lfs_size_t size) {
uint8_t *data = buffer;
if (lfs->block_count &&
(block >= lfs->block_count || off+size > lfs->cfg->block_size)) {
if (off+size > lfs->cfg->block_size || (lfs->block_count && block >= lfs->block_count)) {
return LFS_ERR_CORRUPT;
}

Expand Down

0 comments on commit 6de3fc6

Please sign in to comment.