x86/hvm: Fix boundary check in hvmemul_insn_fetch()

c/s 0943a03037 added some extra protection for overflowing the emulation
instruction cache, but Coverity points out that boundary condition is off by
one when memcpy()'ing out of the buffer.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
This commit is contained in:
Andrew Cooper committed 2017-07-27 11:39:57 +01:00
1 parent a63334ef13
commit 5a992b670b
1 file changed
+2 -2
+2 -2
View File
@@ -958,8 +958,8 @@ int hvmemul_insn_fetch(
* Will we overflow insn_buf[]? This shouldn't be able to happen,
* which means something went wrong with instruction decoding...
*/
if ( insn_off > sizeof(hvmemul_ctxt->insn_buf) ||
(insn_off + bytes) > sizeof(hvmemul_ctxt->insn_buf) )
if ( insn_off >= sizeof(hvmemul_ctxt->insn_buf) ||
(insn_off + bytes) >= sizeof(hvmemul_ctxt->insn_buf) )
{
ASSERT_UNREACHABLE();
return X86EMUL_UNHANDLEABLE;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.