From 97dae8f5bf69a811f8e26eca6105ca65e77fb0bf Mon Sep 17 00:00:00 2001 From: Frode Solheim Date: Sat, 5 Sep 2015 00:47:49 +0200 Subject: [PATCH] hardfile.cpp: trivial changes --- hardfile.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hardfile.cpp b/hardfile.cpp index b04a67c3..6a3eec42 100644 --- a/hardfile.cpp +++ b/hardfile.cpp @@ -620,8 +620,6 @@ int hdf_dup (struct hardfiledata *dhfd, const struct hardfiledata *shfd) return hdf_dup_target (dhfd, shfd); } -extern int get_guid_target (uae_u8 *out); - static uae_u64 vhd_read (struct hardfiledata *hfd, void *v, uae_u64 offset, uae_u64 len) { uae_u64 read; @@ -1927,7 +1925,6 @@ static uae_u32 REGPARAM2 hardfile_open (TrapContext *context) { uaecptr ioreq = m68k_areg (regs, 1); /* IOReq */ int unit = mangleunit (m68k_dreg (regs, 0)); - struct hardfileprivdata *hfpd = &hardfpd[unit]; int err = IOERR_OPENFAIL; /* boot device port size == 0!? KS 1.x size = 12??? @@ -1935,7 +1932,8 @@ static uae_u32 REGPARAM2 hardfile_open (TrapContext *context) * int size = get_word (ioreq + 0x12); */ /* Check unit number */ - if (unit >= 0) { + if (unit >= 0 && unit < MAX_FILESYSTEM_UNITS) { + struct hardfileprivdata *hfpd = &hardfpd[unit]; struct hardfiledata *hfd = get_hardfile_data (unit); if (hfd && (hfd->handle_valid || hfd->drive_empty) && start_thread (context, unit)) { put_word (hfpd->base + 32, get_word (hfpd->base + 32) + 1); @@ -1958,6 +1956,9 @@ static uae_u32 REGPARAM2 hardfile_close (TrapContext *context) { uaecptr request = m68k_areg (regs, 1); /* IOReq */ int unit = mangleunit (get_long (request + 24)); + if (unit < 0 || unit >= MAX_FILESYSTEM_UNITS) { + return 0; + } struct hardfileprivdata *hfpd = &hardfpd[unit]; if (!hfpd) -- 2.47.3