From 35fb3141064841e3e1423b29c41e5d33efdac38d Mon Sep 17 00:00:00 2001 From: Christopher Williams Date: Wed, 9 Jan 2019 17:15:56 -0700 Subject: [PATCH] R0.13c patch 1 December 22, 2018 f_mkfs() function can fail with FR_MKFS_ABORTED if the FAT type is exFAT and the volume is located not at the first partition. --- source/ff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ff.c b/source/ff.c index 7f56871..7b04676 100644 --- a/source/ff.c +++ b/source/ff.c @@ -5642,7 +5642,7 @@ FRESULT f_mkfs ( b_fat = b_vol + 32; /* FAT start at offset 32 */ sz_fat = ((sz_vol / au + 2) * 4 + ss - 1) / ss; /* Number of FAT sectors */ b_data = (b_fat + sz_fat + sz_blk - 1) & ~(sz_blk - 1); /* Align data area to the erase block boundary */ - if (b_data >= sz_vol / 2) LEAVE_MKFS(FR_MKFS_ABORTED); /* Too small volume? */ + if (b_data - b_vol >= sz_vol / 2) LEAVE_MKFS(FR_MKFS_ABORTED); /* Too small volume? */ n_clst = (sz_vol - (b_data - b_vol)) / au; /* Number of clusters */ if (n_clst <16) LEAVE_MKFS(FR_MKFS_ABORTED); /* Too few clusters? */ if (n_clst > MAX_EXFAT) LEAVE_MKFS(FR_MKFS_ABORTED); /* Too many clusters? */