diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2015-02-08 23:36:01 +0100 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2015-02-09 11:01:11 +0100 |
commit | de0c30dded45ea9956a2e7b241ce16641b30492f (patch) | |
tree | cb2d39b7c73b02d1180e57877f21641682c29e6f /src/Common/Fat.c | |
parent | 1ab00f3e3cac1754abcb1d91edf01198b24a32a2 (diff) | |
download | VeraCrypt-de0c30dded45ea9956a2e7b241ce16641b30492f.tar.gz VeraCrypt-de0c30dded45ea9956a2e7b241ce16641b30492f.zip |
Static Code Analysis: handle unused variables more properly. Catch STL exception. Add more checks. Add proper cast to arithmetic operations.
Diffstat (limited to 'src/Common/Fat.c')
-rw-r--r-- | src/Common/Fat.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Common/Fat.c b/src/Common/Fat.c index b6138528..2adafd78 100644 --- a/src/Common/Fat.c +++ b/src/Common/Fat.c @@ -60,7 +60,7 @@ GetFatParams (fatparams * ft) if (ft->cluster_size == 0)
ft->cluster_size = 1;
- if (ft->cluster_size * ft->sector_size > TC_MAX_FAT_CLUSTER_SIZE)
+ if (((unsigned __int64) ft->cluster_size * ft->sector_size) > TC_MAX_FAT_CLUSTER_SIZE)
ft->cluster_size = TC_MAX_FAT_CLUSTER_SIZE / ft->sector_size;
if (ft->cluster_size > 128)
@@ -85,7 +85,7 @@ GetFatParams (fatparams * ft) ft->size_fat = 12;
ft->reserved = 2;
fatsecs = ft->num_sectors - (ft->size_root_dir + ft->sector_size - 1) / ft->sector_size - ft->reserved;
- ft->cluster_count = (int) (((__int64) fatsecs * ft->sector_size) / (ft->cluster_size * ft->sector_size));
+ ft->cluster_count = (int) (((unsigned __int64) fatsecs * ft->sector_size) / ((unsigned __int64) ft->cluster_size * ft->sector_size));
ft->fat_length = (((ft->cluster_count * 3 + 1) >> 1) + ft->sector_size - 1) / ft->sector_size;
if (ft->cluster_count >= 4085) // FAT16
@@ -108,7 +108,7 @@ GetFatParams (fatparams * ft) fatsecs = ft->num_sectors - ft->reserved;
ft->size_root_dir = ft->cluster_size * ft->sector_size;
- ft->cluster_count = (int) (((__int64) fatsecs * ft->sector_size) / (ft->cluster_size * ft->sector_size));
+ ft->cluster_count = (int) (((unsigned __int64) fatsecs * ft->sector_size) / (ft->cluster_size * ft->sector_size));
ft->fat_length = (ft->cluster_count * 4 + ft->sector_size - 1) / ft->sector_size;
// Align data area on TC_MAX_VOLUME_SECTOR_SIZE
@@ -282,7 +282,8 @@ FormatFat (void* hwndDlgPtr, unsigned __int64 startSector, fatparams * ft, void memset (sector, 0, ft->sector_size);
- RandgetBytes (hwndDlg, ft->volume_id, sizeof (ft->volume_id), FALSE);
+ if (!RandgetBytes (hwndDlg, ft->volume_id, sizeof (ft->volume_id), FALSE))
+ goto fail;
PutBoot (ft, (unsigned char *) sector);
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo,
|