Skip to content

Commit

Permalink
fatfs: fix NULL deref in fat32 code
Browse files Browse the repository at this point in the history
setdstart() was checking ISFAT32(dpbp) before dpbp was initialized.
This produced various crashes and inconsistencies.
Just remove the check and store the full cluster count.
On fat16 it shouldn't exceed 16 bits anyway.
  • Loading branch information
stsp committed Dec 6, 2023
1 parent 97f66ce commit a438101
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions kernel/fatfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ CLUSTER getdstart(struct dpb FAR *dpbp, struct dirent *dentry)
void setdstart(struct dpb FAR *dpbp, struct dirent *dentry, CLUSTER value)
{
dentry->dir_start = (UWORD)value;
if (ISFAT32(dpbp))
dentry->dir_start_high = (UWORD)(value >> 16);
dentry->dir_start_high = (UWORD)(value >> 16);
}
#endif

Expand Down

0 comments on commit a438101

Please sign in to comment.