From 1c2de0a45e17fbd5af3cab98ad2b1bc70a801d84 Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Mon, 9 Jul 2007 22:58:08 +0000 Subject: Prevent another divide-by-zero (only affecting targets with FAT16 support enabled, such as the Sansa). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13837 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/fat.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 2ca2b6136d..f117119258 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c @@ -313,6 +313,8 @@ int fat_mount(IF_MV2(int volume,) IF_MV2(int drive,) long startsector) #ifdef HAVE_FAT16SUPPORT fat_bpb->bpb_rootentcnt = BYTES2INT16(buf,BPB_ROOTENTCNT); + if (!fat_bpb->bpb_bytspersec) + return -2; rootdirsectors = secmult * ((fat_bpb->bpb_rootentcnt * DIR_ENTRY_SIZE + fat_bpb->bpb_bytspersec - 1) / fat_bpb->bpb_bytspersec); #endif /* #ifdef HAVE_FAT16SUPPORT */ -- cgit v1.2.3