fix bug when 1-byte opcode will trigger size-limit because of unnecessary bounds check
This commit is contained in:
parent
97c8476d2a
commit
bd6682a61d
3 changed files with 10 additions and 4 deletions
|
|
@ -312,12 +312,16 @@ int rtdisasm_analyze_single(const uint8_t* code, unsigned size, const instructio
|
|||
if (type == INSTRUCTION_STD)
|
||||
{
|
||||
if (ins->config.has_imm)
|
||||
{
|
||||
cur += imm2length(ins->std.imm);
|
||||
else if (ins->config.has_value)
|
||||
cur += value2length(ins->std.value);
|
||||
|
||||
if (cur >= end) return -1;
|
||||
}
|
||||
else if (ins->config.has_value)
|
||||
{
|
||||
cur += value2length(ins->std.value);
|
||||
if (cur >= end) return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// set found
|
||||
if (found) *found = ins;
|
||||
|
|
|
|||
|
|
@ -7,8 +7,9 @@ extern void test_1_end();
|
|||
int main()
|
||||
{
|
||||
size_t size = (uintptr_t)test_1_end - (uintptr_t)test_1;
|
||||
int len = rtdisasm_analyze_single((const uint8_t*)test_1, size, NULL);
|
||||
printf("rtdisasm_analyze_single: len %d\n", len);
|
||||
printf("size %lu\n", size);
|
||||
// int len = rtdisasm_analyze_single((const uint8_t*)test_1, size, NULL);
|
||||
// printf("rtdisasm_analyze_single: len %d\n", len);
|
||||
|
||||
int offset = rtdisasm_find_target((const uint8_t*)test_1, size, RT_TARGET_NOP);
|
||||
printf("rtdisasm_find_target: offset %d\n", offset);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
.globl test_1_end
|
||||
|
||||
test_1:
|
||||
push %rax
|
||||
push (%rbp)
|
||||
|
||||
nop # target that rtdisasm must reach
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue