From 54acc734d23233b25a8a0fc10032c3dd42544231 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Mon, 1 Sep 2014 17:33:11 +0300 Subject: [PATCH] Check and immediately reject negative disk offset if disk access is 64-bit. --- hardfile.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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; } -- 2.47.3