mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 16:14:16 +01:00 
			
		
		
		
	lfs: Validate lfs-cfg sizes before performing arithmetic logics with them
This commit is contained in:
		
							
								
								
									
										6
									
								
								lfs.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								lfs.c
									
									
									
									
									
								
							| @@ -3369,6 +3369,12 @@ static int lfs_init(lfs_t *lfs, const struct lfs_config *cfg) { | |||||||
|     lfs->cfg = cfg; |     lfs->cfg = cfg; | ||||||
|     int err = 0; |     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 |     // check that block size is a multiple of cache size is a multiple | ||||||
|     // of prog and read sizes |     // of prog and read sizes | ||||||
|     LFS_ASSERT(lfs->cfg->cache_size % lfs->cfg->read_size == 0); |     LFS_ASSERT(lfs->cfg->cache_size % lfs->cfg->read_size == 0); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user