From 13c4833d2efb9738416e3e8437c045ff1bdb6737 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Mon, 18 Jun 2018 21:09:47 +0300 Subject: [PATCH] Return READ CAPACITY block count 0xffffffff if number of blocks don't fit in 32-bit variable. --- hardfile.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hardfile.cpp b/hardfile.cpp index f015ab54..fb4e20d6 100644 --- a/hardfile.cpp +++ b/hardfile.cpp @@ -1954,11 +1954,11 @@ int scsi_hd_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, ua { int pmi = cmdbuf[8] & 1; uae_u32 lba = (cmdbuf[2] << 24) | (cmdbuf[3] << 16) | (cmdbuf[4] << 8) | cmdbuf[5]; - uae_u32 blocks; + uae_u64 blocks; int cyl, head, tracksec; if (nodisk (hfd)) goto nodisk; - blocks = (uae_u32)(hfd->virtsize / hfd->ci.blocksize); + blocks = hfd->virtsize / hfd->ci.blocksize; if (hfd->ci.max_lba) blocks = hfd->ci.max_lba; if (hdhfd) { @@ -1979,7 +1979,7 @@ int scsi_hd_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, ua lba = blocks; blocks = lba; } - wl (r, blocks - 1); + wl (r, (uae_u32)(blocks <= 0x100000000 ? blocks - 1 : 0xffffffff)); wl (r + 4, hfd->ci.blocksize); scsi_len = lr = 8; } -- 2.47.3