From: Toni Wilen Date: Sun, 28 Sep 2014 13:53:21 +0000 (+0300) Subject: Log SCSI emulation out of bounds accesses and full size of vhd files. X-Git-Tag: 3000~30 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=9c65ef38be1957502194bfbd4d96d5dfa7cabd85;p=francis%2Fwinuae.git Log SCSI emulation out of bounds accesses and full size of vhd files. --- diff --git a/hardfile.cpp b/hardfile.cpp index 2fbf8b21..089980bd 100644 --- a/hardfile.cpp +++ b/hardfile.cpp @@ -569,9 +569,9 @@ int hdf_open (struct hardfiledata *hfd, const TCHAR *pname) hfd->vhd_sectormapblock = -1; hfd->vhd_bitmapsize = ((hfd->vhd_blocksize / (8 * 512)) + 511) & ~511; } - write_log (_T("HDF is VHD %s image, virtual size=%lldK\n"), + write_log (_T("HDF is VHD %s image, virtual size=%lldK (%llx %lld)\n"), hfd->hfd_type == HFD_VHD_FIXED ? _T("fixed") : _T("dynamic"), - hfd->virtsize / 1024); + hfd->virtsize / 1024, hfd->virtsize, hfd->virtsize); hdf_init_cache (hfd); return 1; nonvhd: @@ -1179,12 +1179,13 @@ static uae_u64 cmd_write (struct hardfiledata *hfd, uaecptr dataptr, uae_u64 off static int checkbounds (struct hardfiledata *hfd, uae_u64 offset, uae_u64 len) { - if (offset >= hfd->virtsize) - return 0; - if (offset + len > hfd->virtsize) - return 0; - if (offset > 0xffffffff && (uae_s64)offset < 0) + uae_u64 max = hfd->virtsize; + if (offset >= max || offset + len > max || (offset > 0xffffffff && (uae_s64)offset < 0)) { + write_log (_T("UAEHF SCSI: out of bounds, %08X-%08X + %08X-%08X > %08X-%08X\n"), + (uae_u32)(offset >> 32),(uae_u32)offset,(uae_u32)(len >> 32),(uae_u32)len, + (uae_u32)(max >> 32),(uae_u32)max); return 0; + } return 1; }