mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 05:08:41 +08:00
fs/fat/fs_fat32util.c: fix potential exception due to dividing zero during mounting when fat is corrupted
Check fs_fatsecperclus' value when read from eMMC device. Return an error if it is zero. Signed-off-by: Yinzhe Wu <Yinzhe.Wu@sony.com> Reviewed-by: Jacky Cao <Jacky.Cao@sony.com> Tested-by: Yinzhe Wu <Yinzhe.Wu@sony.com>
This commit is contained in:
parent
15250540eb
commit
5cdc6c77cf
1 changed files with 5 additions and 0 deletions
|
@ -213,6 +213,11 @@ static int fat_checkbootrecord(struct fat_mountpt_s *fs)
|
||||||
/* Get the sectors per cluster */
|
/* Get the sectors per cluster */
|
||||||
|
|
||||||
fs->fs_fatsecperclus = FBR_GETSECPERCLUS(fs->fs_buffer);
|
fs->fs_fatsecperclus = FBR_GETSECPERCLUS(fs->fs_buffer);
|
||||||
|
if (fs->fs_fatsecperclus == 0)
|
||||||
|
{
|
||||||
|
fwarn("WARNING: sectors per cluster cannot be 0\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Calculate the number of clusters */
|
/* Calculate the number of clusters */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue