Merge pull request #337 from ARMmbed/fix-null-fetchmatch

fix nullptr access in lfs_dir_fetchmatch (#185)
This commit is contained in:
Christopher Haster
2019-12-01 16:24:44 -06:00
committed by GitHub

6
lfs.c
View File

@@ -975,9 +975,10 @@ static lfs_stag_t lfs_dir_fetchmatch(lfs_t *lfs,
static int lfs_dir_fetch(lfs_t *lfs, static int lfs_dir_fetch(lfs_t *lfs,
lfs_mdir_t *dir, const lfs_block_t pair[2]) { lfs_mdir_t *dir, const lfs_block_t pair[2]) {
// note, mask=-1, tag=0 can never match a tag since this // note, mask=-1, tag=-1 can never match a tag since this
// pattern has the invalid bit set // pattern has the invalid bit set
return (int)lfs_dir_fetchmatch(lfs, dir, pair, -1, 0, NULL, NULL, NULL); return (int)lfs_dir_fetchmatch(lfs, dir, pair,
(lfs_tag_t)-1, (lfs_tag_t)-1, NULL, NULL, NULL);
} }
static int lfs_dir_getgstate(lfs_t *lfs, const lfs_mdir_t *dir, static int lfs_dir_getgstate(lfs_t *lfs, const lfs_mdir_t *dir,
@@ -1647,7 +1648,6 @@ relocate:
if (err && (err != LFS_ERR_NOSPC && !exhausted)) { if (err && (err != LFS_ERR_NOSPC && !exhausted)) {
return err; return err;
} }
continue; continue;
} }