summaryrefslogtreecommitdiffstats
path: root/src/exfat.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2015-12-22 15:23:11 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2015-12-22 15:23:11 +0100
commitc19ec047b8d6e7ca6dedd787098ef692ce3e75fd (patch)
tree5ba2fdfee9fde2bbc15e3b93e861815b2b8b8e42 /src/exfat.c
parent41120e6174a1785fc0400c1b8af43cce777cf055 (diff)
Better handle exFAT partition with damaged boot sector
Diffstat (limited to 'src/exfat.c')
-rw-r--r--src/exfat.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/exfat.c b/src/exfat.c
index d74a598..9e7ddf2 100644
--- a/src/exfat.c
+++ b/src/exfat.c
@@ -33,6 +33,9 @@
#include "types.h"
#include "common.h"
#include "exfat.h"
+#include "log.h"
+
+extern const arch_fnct_t arch_none;
uint64_t exfat_cluster_to_offset(const struct exfat_super_block *exfat_header, const unsigned int cluster)
{
@@ -95,8 +98,15 @@ int recover_EXFAT(const disk_t *disk, const struct exfat_super_block *exfat_head
partition->part_type_i386=P_EXFAT;
partition->part_type_gpt=GPT_ENT_TYPE_MS_BASIC_DATA;
partition->part_size=(uint64_t)le64(exfat_header->nr_sectors) * disk->sector_size;
- if(le64(exfat_header->start_sector) +
- (12 << exfat_header->blocksize_bits) == partition->part_offset)
+#ifdef DEBUG_EXFAT
+ log_info("recover_EXFAT:\n");
+ log_info("start_sector=%llu\n", (long long unsigned)le64(exfat_header->start_sector));
+ log_info("blocksize=%u\n", (12<<exfat_header->blocksize_bits));
+ log_info("part_offset=%llu\n", partition->part_offset);
+#endif
+ if((le64(exfat_header->start_sector) * disk ->sector_size +
+ (12 << exfat_header->blocksize_bits) == partition->part_offset) ||
+ (disk->arch==&arch_none && (12 << exfat_header->blocksize_bits) == partition->part_offset))
{
partition->sb_offset=12 << exfat_header->blocksize_bits;
partition->part_offset-=partition->sb_offset;