littlefs: Fix block addr overflow

deepikabhavnani did the hard work in tracking this issue down.  Block
addresses are not cast to the correct type until after multiplying to
convert to byte addresses. This results in an overflow when the storage
is larger than 4 GB.
pull/5954/head
Christopher Haster 2018-01-12 14:44:44 -06:00 committed by Cruz Monrreal II‰
parent 3ca6c55feb
commit 388041afeb
1 changed files with 3 additions and 3 deletions

View File

@ -85,19 +85,19 @@ static int lfs_totype(int type)
static int lfs_bd_read(const struct lfs_config *c, lfs_block_t block,
lfs_off_t off, void *buffer, lfs_size_t size) {
BlockDevice *bd = (BlockDevice *)c->context;
return bd->read(buffer, block*c->block_size + off, size);
return bd->read(buffer, (bd_addr_t)block*c->block_size + off, size);
}
static int lfs_bd_prog(const struct lfs_config *c, lfs_block_t block,
lfs_off_t off, const void *buffer, lfs_size_t size) {
BlockDevice *bd = (BlockDevice *)c->context;
return bd->program(buffer, block*c->block_size + off, size);
return bd->program(buffer, (bd_addr_t)block*c->block_size + off, size);
}
static int lfs_bd_erase(const struct lfs_config *c, lfs_block_t block)
{
BlockDevice *bd = (BlockDevice *)c->context;
return bd->erase(block*c->block_size, c->block_size);
return bd->erase((bd_addr_t)block*c->block_size, c->block_size);
}
static int lfs_bd_sync(const struct lfs_config *c)