From 814cf62a8576ea7a16fa67e082dcf283cece6d3d Mon Sep 17 00:00:00 2001 From: kobalicek Date: Fri, 3 Feb 2017 17:50:51 +0100 Subject: [PATCH] Added validation of absolute memory address to the validator --- src/asmjit/x86/x86inst.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/asmjit/x86/x86inst.cpp b/src/asmjit/x86/x86inst.cpp index a4fc55a..d70dc9b 100644 --- a/src/asmjit/x86/x86inst.cpp +++ b/src/asmjit/x86/x86inst.cpp @@ -3821,6 +3821,13 @@ ASMJIT_FAVOR_SIZE Error X86Inst::validate( if (!indexType && !m.getOffsetLo32()) memFlags |= X86Inst::kMemOpBaseOnly; } + else { + // Base is an address, make sure that the address doesn't overflow 32-bit + // integer (either int32_t or uint32_t) in 32-bit targets. + int64_t offset = m.getOffset(); + if (archMask == X86Inst::kArchMaskX86 && !Utils::isInt32(offset) && !Utils::isUInt32(offset)) + return DebugUtils::errored(kErrorInvalidAddress); + } if (indexType) { if (ASMJIT_UNLIKELY((vd->allowedMemIndexRegs & (1U << indexType)) == 0))