Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/littlefs-project/littlefs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Haster <chaster@utexas.edu>2019-09-19 18:02:54 +0300
committerGitHub <noreply@github.com>2019-09-19 18:02:54 +0300
commitfd204ac2fb4e05ffce6db6d1be67e0342c267cd7 (patch)
tree5db758e9eb1ab3f3835d1a96e4c8da58b28c66de
parentbd99402d9aaef2d965d8fbe085647eadc9db4c68 (diff)
parent0c77123eeeadae9e8a02461d1fb4d023fbf3aa47 (diff)
Merge pull request #278 from roykuper13/validate-lfs-cfg-sizesv2.1.2
lfs: Validate lfs-cfg sizes before performing any arithmetic logics with them
-rw-r--r--lfs.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lfs.c b/lfs.c
index d9e3ffb..e2ab1e5 100644
--- a/lfs.c
+++ b/lfs.c
@@ -3369,6 +3369,12 @@ static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) {
lfs->cfg = cfg;
int err = 0;
+ // validate that the lfs-cfg sizes were initiated properly before
+ // performing any arithmetic logics with them
+ LFS_ASSERT(lfs->cfg->read_size != 0);
+ LFS_ASSERT(lfs->cfg->prog_size != 0);
+ LFS_ASSERT(lfs->cfg->cache_size != 0);
+
// check that block size is a multiple of cache size is a multiple
// of prog and read sizes
LFS_ASSERT(lfs->cfg->cache_size % lfs->cfg->read_size == 0);