src/cpu/x86/vm/templateTable_x86_32.cpp
Print this page
rev 5510 : 8027252: Crash in interpreter because get_unsigned_2_byte_index_at_bcp reads 4 bytes
Summary: Use 2-byte loads to load indexes from the byte code stream to avoid out of bounds reads.
Reviewed-by:
@@ -556,11 +556,11 @@
__ movptr(rax, aaddress(rbx));
}
void TemplateTable::locals_index_wide(Register reg) {
- __ movl(reg, at_bcp(2));
+ __ load_unsigned_short(reg, at_bcp(2));
__ bswapl(reg);
__ shrl(reg, 16);
__ negptr(reg);
}
@@ -1550,11 +1550,15 @@
InvocationCounter::counter_offset();
const ByteSize inv_offset = MethodCounters::invocation_counter_offset() +
InvocationCounter::counter_offset();
// Load up EDX with the branch displacement
+ if (is_wide) {
__ movl(rdx, at_bcp(1));
+ } else {
+ __ load_signed_short(rdx, at_bcp(1));
+ }
__ bswapl(rdx);
if (!is_wide) __ sarl(rdx, 16);
LP64_ONLY(__ movslq(rdx, rdx));