Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions jdk/src/share/native/common/check_code.c
Original file line number Diff line number Diff line change
Expand Up @@ -1161,10 +1161,11 @@ verify_opcode_operands(context_type *context, unsigned int inumber, int offset)
case JVM_OPC_if_acmpeq: case JVM_OPC_if_acmpne:
case JVM_OPC_goto: {
/* Set the ->operand to be the instruction number of the target. */
int jump = (((signed char)(code[offset+1])) << 8) + code[offset+2];
int jump, target;
jump = (((signed char)(code[offset+1])) << 8) + code[offset+2];
if (!isLegalOffset(context, offset, jump))
CCerror(context, "Illegal target of jump or branch");
int target = offset + jump;
target = offset + jump;
this_idata->operand.i = code_data[target];
break;
}
Expand All @@ -1175,12 +1176,13 @@ verify_opcode_operands(context_type *context, unsigned int inumber, int offset)
/* FALLTHROUGH */
case JVM_OPC_goto_w: {
/* Set the ->operand to be the instruction number of the target. */
int jump = (((signed char)(code[offset+1])) << 24) +
int jump, target;
jump = (((signed char)(code[offset+1])) << 24) +
(code[offset+2] << 16) + (code[offset+3] << 8) +
(code[offset + 4]);
if (!isLegalOffset(context, offset, jump))
CCerror(context, "Illegal target of jump or branch");
int target = offset + jump;
target = offset + jump;
this_idata->operand.i = code_data[target];
break;
}
Expand All @@ -1193,6 +1195,7 @@ verify_opcode_operands(context_type *context, unsigned int inumber, int offset)
int *saved_operand;
int keys;
int k, delta;
int jump, target;

if (context->major_version < NONZERO_PADDING_BYTES_IN_SWITCH_MAJOR_VERSION) {
/* 4639449, 4647081: Padding bytes must be zero. */
Expand All @@ -1219,10 +1222,10 @@ verify_opcode_operands(context_type *context, unsigned int inumber, int offset)
}
}
saved_operand = NEW(int, keys + 2);
int jump = _ck_ntohl(lpc[0]);
jump = _ck_ntohl(lpc[0]);
if (!isLegalOffset(context, offset, jump))
CCerror(context, "Illegal default target in switch");
int target = offset + jump;
target = offset + jump;
saved_operand[keys + 1] = code_data[target];
for (k = keys, lptr = &lpc[3]; --k >= 0; lptr += delta) {
jump = _ck_ntohl(lptr[0]);
Expand Down Expand Up @@ -1765,8 +1768,9 @@ isLegalOffset(context_type *context, int bci, int offset)
int *code_data = context->code_data;
int max_offset = 65535; // JVMS 4.11
int min_offset = -65535;
int target;
if (offset < min_offset || offset > max_offset) return JNI_FALSE;
int target = bci + offset;
target = bci + offset;
return (target >= 0 && target < code_length && code_data[target] >= 0);
}

Expand Down