mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-21 04:14:34 +00:00
fs: fat: avoid NULL dereference when root dir is full
When trying to create a file in the full root directory of a FAT32
filesystem a NULL dereference can be observed.
When the root directory of a FAT16 filesystem is full fill_dir_slot() must
return -1 to signal that a new directory entry could not be allocated.
Fixes: cd2d727fff
("fs: fat: allocate a new cluster for root directory of fat32")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
parent
7889951d0f
commit
661d223868
1 changed files with 2 additions and 3 deletions
|
@ -260,9 +260,8 @@ fill_dir_slot(fat_itr *itr, const char *l_name)
|
||||||
flush_dir(itr);
|
flush_dir(itr);
|
||||||
|
|
||||||
/* allocate a cluster for more entries */
|
/* allocate a cluster for more entries */
|
||||||
if (!fat_itr_next(itr))
|
if (!fat_itr_next(itr) && !itr->dent)
|
||||||
if (!itr->dent &&
|
if ((itr->is_root && itr->fsdata->fatsize != 32) ||
|
||||||
(!itr->is_root || itr->fsdata->fatsize == 32) &&
|
|
||||||
new_dir_table(itr))
|
new_dir_table(itr))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue