Commit 82a0cd80 authored by Ben Avison's avatar Ben Avison
Browse files

Fix divide-by-zero bug

  Somewhere in the process of adding FAT16/FAT32 support, a bug was
  was introduced where an attempt was made to calculate the number of
  sectors in a cluster before the cluster size (in bytes) had been
  determined. This affected invalid (e.g. blank) image files, as well as
  old 160K/320K DOS floppies that aren't supposed to contain a valid boot
  Issue raised by the Raspberry Pi NOOBS team when they failed to set up
  the DOS partition where FileCore was expecting it to be.

Version 1.02. Tagged as 'DOSFS-1_02'
parent 6d572cd3
/* (1.01)
/* (1.02)
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
#define Module_MajorVersion_CMHG 1.01
#define Module_MajorVersion_CMHG 1.02
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 13 Jan 2013
#define Module_Date_CMHG 15 Oct 2013
#define Module_MajorVersion "1.01"
#define Module_Version 101
#define Module_MajorVersion "1.02"
#define Module_Version 102
#define Module_MinorVersion ""
#define Module_Date "13 Jan 2013"
#define Module_Date "15 Oct 2013"
#define Module_ApplicationDate "13-Jan-13"
#define Module_ApplicationDate "15-Oct-13"
#define Module_ComponentName "DOSFS"
#define Module_ComponentPath "castle/RiscOS/Sources/FileSys/ImageFS/DOSFS"
#define Module_FullVersion "1.01"
#define Module_HelpVersion "1.01 (13 Jan 2013)"
#define Module_LibraryVersionInfo "1:1"
#define Module_FullVersion "1.02"
#define Module_HelpVersion "1.02 (15 Oct 2013)"
#define Module_LibraryVersionInfo "1:2"
......@@ -497,7 +497,11 @@ DOSdisc *DOSFS_image_open(word fshand, word buffsize)
datasec = totsec - ((dboot->BOOT_reserved | (dboot->BOOT_reservedHI<<8)) + (numFATs * FATsize) + RootDirSectors);
dprintf(("","DOSFS_image_open: FATsize = %x\n",FATsize));
dprintf(("","DOSFS_image_open: totsec = %x\n",totsec));
CountOfClusters = datasec / dboot->BOOT_secalloc;
/* In the case where it's a 320K/160K floppy, we won't know secalloc until we
* deduce it from the FAT, which we don't read until later. However,
* CountOfClusters is only used for distinguishing FAT12/Fat16/FAT32, and for
* these purposes, assuming 1 sector per cluster will be fine */
CountOfClusters = dboot->BOOT_secalloc > 0 ? datasec / dboot->BOOT_secalloc : datasec;
dprintf(("","DOSFS_image_open: CountOfClusters = %x\n",CountOfClusters));
/* allocate a DOS disc description structure large enough to hold a FAT
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment