summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2018-09-22 09:15:37 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2018-09-22 09:15:37 +0200
commit9d8b1382c951b82a54c2de94348450447f59ee09 (patch)
tree167e20153c4fa910618357ee6a55ba30e95d97ee
parentd8eb31055c362dcc1d2ec6a0b0427972508c5a32 (diff)
exfat: fix to use 64 bits for some variables
-rw-r--r--src/exfat.h2
-rw-r--r--src/exfat_dir.c15
-rw-r--r--src/exfatp.c2
3 files changed, 10 insertions, 9 deletions
diff --git a/src/exfat.h b/src/exfat.h
index fc1ff4d..0037f77 100644
--- a/src/exfat.h
+++ b/src/exfat.h
@@ -40,7 +40,7 @@ struct exfat_super_block {
unsigned char xxxx01; /* ??? (0x00 or any value (?)) */
unsigned char xxxx02; /* ??? (0x01 or 0x00 (?)) */
uint16_t state; /* state of this volume */
- unsigned char blocksize_bits; /* bits of block size */
+ unsigned char blocksize_bits; /* 0x6c bits of block size */
unsigned char block_per_clus_bits; /* bits of blocks per cluster */
unsigned char number_of_fats;
unsigned char drive_select; /* Used by INT 13 */
diff --git a/src/exfat_dir.c b/src/exfat_dir.c
index 959843e..16a1326 100644
--- a/src/exfat_dir.c
+++ b/src/exfat_dir.c
@@ -107,15 +107,15 @@ static int exfat_ucstoutf8(iconv_t cd, const unsigned char *ins, const unsigned
#define ATTR_DIR 16 /* directory */
#define ATTR_ARCH 32 /* archived */
-static unsigned int exfat_get_next_cluster(disk_t *disk_car,const partition_t *partition, const int offset, const unsigned int cluster)
+static unsigned int exfat_get_next_cluster(disk_t *disk_car,const partition_t *partition, const uint64_t offset, const unsigned int cluster)
{
unsigned char *buffer=(unsigned char*)MALLOC(disk_car->sector_size);
unsigned int next_cluster;
const uint32_t *p32=(const uint32_t*)buffer;
- const unsigned long int offset_s=cluster/(disk_car->sector_size/4);
- const unsigned long int offset_o=cluster%(disk_car->sector_size/4);
+ const uint64_t offset_s=cluster / (disk_car->sector_size/4);
+ const uint64_t offset_o=cluster % (disk_car->sector_size/4);
if((unsigned)disk_car->pread(disk_car, buffer, disk_car->sector_size,
- partition->part_offset + offset + (uint64_t)offset_s * disk_car->sector_size) != disk_car->sector_size)
+ partition->part_offset + offset + offset_s * disk_car->sector_size) != disk_car->sector_size)
{
log_error("exfat_get_next_cluster read error\n");
free(buffer);
@@ -234,7 +234,7 @@ static int exfat_dir(disk_t *disk, const partition_t *partition, dir_data_t *dir
const unsigned int total_clusters=le32(exfat_header->total_clusters);
exfat_method_t exfat_meth=exFAT_FOLLOW_CLUSTER;
int stop=0;
- const uint64_t start_exfat1=le32(exfat_header->fat_blocknr) << exfat_header->blocksize_bits;
+ const uint64_t start_exfat1=(uint64_t)le32(exfat_header->fat_blocknr) << exfat_header->blocksize_bits;
if(first_cluster<2)
cluster=le32(exfat_header->rootdir_clusnr);
else
@@ -368,7 +368,8 @@ static int exfat_copy(disk_t *disk, const partition_t *partition, dir_data_t *di
unsigned int cluster;
uint64_t file_size=file->st_size;
exfat_method_t exfat_meth=exFAT_FOLLOW_CLUSTER;
- uint64_t start_exfat1,clus_blocknr;
+ uint64_t start_exfat1;
+ unsigned long int clus_blocknr;
unsigned long int total_clusters;
f_out=fopen_local(&new_file, dir_data->local_dir, dir_data->current_directory);
if(!f_out)
@@ -379,7 +380,7 @@ static int exfat_copy(disk_t *disk, const partition_t *partition, dir_data_t *di
return -1;
}
cluster = file->st_ino;
- start_exfat1=le32(exfat_header->fat_blocknr) << exfat_header->blocksize_bits;
+ start_exfat1=(uint64_t)le32(exfat_header->fat_blocknr) << exfat_header->blocksize_bits;
clus_blocknr=le32(exfat_header->clus_blocknr);
total_clusters=le32(exfat_header->total_clusters);
log_trace("exfat_copy dst=%s first_cluster=%u (%llu) size=%lu\n", new_file,
diff --git a/src/exfatp.c b/src/exfatp.c
index e5668f9..00374ac 100644
--- a/src/exfatp.c
+++ b/src/exfatp.c
@@ -67,7 +67,7 @@ unsigned int exfat_remove_used_space(disk_t *disk, const partition_t *partition,
unsigned char *buffer;
unsigned int i;
unsigned int cluster_bitmap;
- const uint64_t start_exfat1=le32(exfat_header->fat_blocknr) << exfat_header->blocksize_bits;
+ const uint64_t start_exfat1=(uint64_t)le32(exfat_header->fat_blocknr) << exfat_header->blocksize_bits;
uint64_t start_free=0;
uint64_t end_free=0;
if(disk->pread(disk, buffer_rootdir, 1 << cluster_shift, start) != (1<<cluster_shift))