mirror of
https://github.com/holub/mame
synced 2025-05-06 14:25:54 +03:00
imd_dsk.cpp: Add some sanity checking on geometry
This commit is contained in:
parent
c72d28ba0c
commit
952bdf962a
@ -433,6 +433,9 @@ bool imd_format::load(io_generic *io, uint32_t form_factor, floppy_image *image)
|
|||||||
if(pos >= size)
|
if(pos >= size)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
int tracks, heads;
|
||||||
|
image->get_maximal_geometry(tracks, heads);
|
||||||
|
|
||||||
while(pos < size) {
|
while(pos < size) {
|
||||||
uint8_t mode = img[pos++];
|
uint8_t mode = img[pos++];
|
||||||
uint8_t track = img[pos++];
|
uint8_t track = img[pos++];
|
||||||
@ -440,8 +443,23 @@ bool imd_format::load(io_generic *io, uint32_t form_factor, floppy_image *image)
|
|||||||
uint8_t sector_count = img[pos++];
|
uint8_t sector_count = img[pos++];
|
||||||
uint8_t ssize = img[pos++];
|
uint8_t ssize = img[pos++];
|
||||||
|
|
||||||
|
if(track >= tracks)
|
||||||
|
{
|
||||||
|
osd_printf_error("imd_format: Track %d exceeds maximum of %d\n", track, tracks);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((head & 0x3f) >= heads)
|
||||||
|
{
|
||||||
|
osd_printf_error("imd_format: Head %d exceeds maximum of %d\n", head & 0x3f, heads);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(ssize == 0xff)
|
if(ssize == 0xff)
|
||||||
throw emu_fatalerror("imd_format: Unsupported variable sector size on track %d head %d", track, head);
|
{
|
||||||
|
osd_printf_error("imd_format: Unsupported variable sector size on track %d head %d", track, head & 0x3f);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t actual_size = ssize < 7 ? 128 << ssize : 8192;
|
uint32_t actual_size = ssize < 7 ? 128 << ssize : 8192;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user