diff options
Diffstat (limited to 'fs/fat/fat.c')
-rw-r--r-- | fs/fat/fat.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 4bc3030ab88..ac8913e7192 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -571,6 +571,17 @@ static int get_fs_info(fsdata *mydata) mydata->sect_size, cur_part_info.blksz); return -1; } + if (mydata->clust_size == 0) { + printf("Error: FAT cluster size not set\n"); + return -1; + } + if ((unsigned int)mydata->clust_size * mydata->sect_size > + MAX_CLUSTSIZE) { + printf("Error: FAT cluster size too big (cs=%u, max=%u)\n", + (unsigned int)mydata->clust_size * mydata->sect_size, + MAX_CLUSTSIZE); + return -1; + } if (mydata->fatsize == 32) { mydata->data_begin = mydata->rootdir_sect - @@ -810,6 +821,9 @@ static dir_entry *extract_vfat_name(fat_itr *itr) slot2str((dir_slot *)dent, buf, &idx); + if (n + idx >= sizeof(itr->l_name)) + return NULL; + /* shift accumulated long-name up and copy new part in: */ memmove(itr->l_name + idx, itr->l_name, n); memcpy(itr->l_name, buf, idx); |