From: Toni Wilen Date: Mon, 1 Sep 2014 14:33:11 +0000 (+0300) Subject: Check and immediately reject negative disk offset if disk access is 64-bit. X-Git-Tag: 3000~66 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=54acc734d23233b25a8a0fc10032c3dd42544231;p=francis%2Fwinuae.git Check and immediately reject negative disk offset if disk access is 64-bit. --- diff --git a/hardfile.cpp b/hardfile.cpp index d5dc0baa..2fbf8b21 100644 --- a/hardfile.cpp +++ b/hardfile.cpp @@ -1183,6 +1183,8 @@ static int checkbounds (struct hardfiledata *hfd, uae_u64 offset, uae_u64 len) return 0; if (offset + len > hfd->virtsize) return 0; + if (offset > 0xffffffff && (uae_s64)offset < 0) + return 0; return 1; } @@ -1897,7 +1899,7 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata unaligned (cmd, offset64, len, hfd->ci.blocksize); goto bad_len; } - if (len + offset64 > hfd->virtsize) { + if (len + offset64 > hfd->virtsize || (uae_s64)offset64 < 0) { outofbounds (cmd, offset64, len, hfd->virtsize); goto bad_len; } @@ -1948,7 +1950,7 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata unaligned (cmd, offset64, len, hfd->ci.blocksize); goto bad_len; } - if (len + offset64 > hfd->virtsize) { + if (len + offset64 > hfd->virtsize || (uae_s64)offset64 < 0) { outofbounds (cmd, offset64, len, hfd->virtsize); goto bad_len; }