- 
        Couldn't load subscription status. 
- Fork 931
Open
Description
We mocked a blockdevice in a way that it falsifies data to program when littleFS tries to commit a crc after writing a file. While littleFS looks for new free space (which it can't find) it produces a hard fault by a nullptr access.
lfs_dir_fetch calls lfs_dir_fetchmatch with a NULL callback, stating that this is ok since an invalid bit is set.
It turns out, that after some iterations of calling lfs_dir_fetch the tag loaded within lfs_dir_fetchmatch becomes 0, gets matched and the NULL callbackpointer is invoked.
I'm proposing following fix:
static int lfs_dir_fetch(lfs_t *lfs,
        lfs_mdir_t *dir, const lfs_block_t pair[2]) {
    // note, mask=-1, tag=-1 can never match a tag since this
    // pattern has the invalid bit set
    return lfs_dir_fetchmatch(lfs, dir, pair, -1, -1, NULL, NULL, NULL);
}
instead of
static int lfs_dir_fetch(lfs_t *lfs,
        lfs_mdir_t *dir, const lfs_block_t pair[2]) {
    // note, mask=-1, tag=0 can never match a tag since this
    // pattern has the invalid bit set
    return lfs_dir_fetchmatch(lfs, dir, pair, -1, 0, NULL, NULL, NULL);
}
Metadata
Metadata
Assignees
Labels
No labels