summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/fat.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c
index 0b8451a5c6..fb75355898 100644
--- a/firmware/drivers/fat.c
+++ b/firmware/drivers/fat.c
@@ -624,13 +624,18 @@ static int bpb_is_sane(IF_MV_NONVOID(struct bpb* fat_bpb))
624 fat_bpb->bpb_bytspersec); 624 fat_bpb->bpb_bytspersec);
625 return -1; 625 return -1;
626 } 626 }
627 if((long)fat_bpb->bpb_secperclus * (long)fat_bpb->bpb_bytspersec 627 if((long)fat_bpb->bpb_secperclus * SECTOR_SIZE > 128L*1024L)
628 > 128L*1024L)
629 { 628 {
629 /* We don't multiply by bpb_bytspersec here, because
630 * back in fat_mount_internal() bpb_secperclus has been
631 * "normalised" to 512 byte clusters, by multiplying with
632 * secmult. */
630 DEBUGF( "bpb_is_sane() - Error: cluster size is larger than 128K " 633 DEBUGF( "bpb_is_sane() - Error: cluster size is larger than 128K "
631 "(%d * %d = %d)\n", 634 "(%d * %d = %d)\n",
632 fat_bpb->bpb_bytspersec, fat_bpb->bpb_secperclus, 635 fat_bpb->bpb_bytspersec,
633 fat_bpb->bpb_bytspersec * fat_bpb->bpb_secperclus); 636 fat_bpb->bpb_secperclus / (fat_bpb->bpb_bytspersec / SECTOR_SIZE),
637 fat_bpb->bpb_bytspersec * fat_bpb->bpb_secperclus /
638 (fat_bpb->bpb_bytspersec / SECTOR_SIZE));
634 return -2; 639 return -2;
635 } 640 }
636 if(fat_bpb->bpb_numfats != 2) 641 if(fat_bpb->bpb_numfats != 2)