From 2f25b5c1e87cf983be221a851ca593f3a2b0b90e Mon Sep 17 00:00:00 2001 From: Matt Harlum Date: Wed, 22 Oct 2025 08:38:12 +0000 Subject: [PATCH] Fix emulated scsi read/write bounds check This was off by one making the last sector inaccessible --- iotask.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iotask.c b/iotask.c index cad2c5c..176fff1 100644 --- a/iotask.c +++ b/iotask.c @@ -172,7 +172,7 @@ static BYTE handle_scsi_command(struct IOStdReq *ioreq) { count = ((struct SCSI_CDB_16 *)command)->length; do_scsi_transfer: - if (data == NULL || (lba + count) >= unit->logicalSectors) { + if (data == NULL || (lba + count) > unit->logicalSectors) { error = IOERR_BADADDRESS; fake_scsi_sense(scsi_command,lba,count,error); break; @@ -501,7 +501,7 @@ transfer: } if ((lba + count) > (unit->logicalSectors)) { - Trace("Read past end of device\n"); + Trace("Access past end of device\n"); error = IOERR_BADADDRESS; break; }