summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/formats/jvc_dsk.cpp
diff options
context:
space:
mode:
author Tomer Verona <tverona@hotmail.com>2016-09-14 11:30:55 -0700
committer Tomer Verona <tverona@hotmail.com>2016-09-14 11:30:55 -0700
commit44a63fccb71ea83eaa137f1ac6e71a60a1fceec3 (patch)
tree8bf67f097af09123d8f94dc1615f29cc2e56a26f /src/lib/formats/jvc_dsk.cpp
parent7c6ddc1e4c79d77ad08af0163939a06d207b097a (diff)
parent568540cec5cee474290fe9e26a27c382114af885 (diff)
Merge remote-tracking branch 'mamedev/master'
Diffstat (limited to 'src/lib/formats/jvc_dsk.cpp')
-rw-r--r--src/lib/formats/jvc_dsk.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lib/formats/jvc_dsk.cpp b/src/lib/formats/jvc_dsk.cpp
index 30ec8287f22..ce364d9efe2 100644
--- a/src/lib/formats/jvc_dsk.cpp
+++ b/src/lib/formats/jvc_dsk.cpp
@@ -37,16 +37,19 @@ const char *jvc_format::extensions() const
bool jvc_format::parse_header(io_generic *io, int &header_size, int &tracks, int &heads, int &sectors, int &sector_size, int &base_sector_id)
{
+ // The JVC format has a header whose size is the size of the image modulo 256. Currently, we only
+ // handle up to five header bytes
UINT64 size = io_generic_size(io);
header_size = size % 256;
UINT8 header[5];
+ // if we know that this is a header of a bad size, we can fail
+ // immediately; otherwise read the header
+ if (header_size >= sizeof(header))
+ return false;
if (header_size > 0)
io_generic_read(io, header, 0, header_size);
- if (header_size > 5)
- return false;
-
// default values
heads = 1;
sectors = 18;