implements PR-O4.6
This commit is contained in:
+22
@@ -61,6 +61,21 @@ class BytecodeLinkPrecheckServiceTest {
|
||||
assertEquals(BytecodeMarshalingErrorCode.MARSHAL_VERIFY_PRECHECK_HOSTCALL_INDEX_INVALID, thrown.code());
|
||||
}
|
||||
|
||||
@Test
|
||||
void validateMustRejectUnknownOpcode() {
|
||||
final var module = new BytecodeModule(
|
||||
0,
|
||||
ReadOnlyList.empty(),
|
||||
ReadOnlyList.from(new BytecodeModule.FunctionMeta(0, 4, 0, 0, 0, 1)),
|
||||
codeUnknownThenRet(),
|
||||
null,
|
||||
ReadOnlyList.empty(),
|
||||
ReadOnlyList.empty());
|
||||
|
||||
final var thrown = assertThrows(BytecodeMarshalingException.class, () -> service.validate(module));
|
||||
assertEquals(BytecodeMarshalingErrorCode.MARSHAL_VERIFY_PRECHECK_UNKNOWN_OPCODE, thrown.code());
|
||||
}
|
||||
|
||||
private byte[] codeHostcall(final int index) {
|
||||
final var out = ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN);
|
||||
out.putShort((short) 0x71);
|
||||
@@ -74,4 +89,11 @@ class BytecodeLinkPrecheckServiceTest {
|
||||
out.putShort((short) 0x51);
|
||||
return out.array();
|
||||
}
|
||||
|
||||
private byte[] codeUnknownThenRet() {
|
||||
final var out = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN);
|
||||
out.putShort((short) 0x7FFF);
|
||||
out.putShort((short) 0x51);
|
||||
return out.array();
|
||||
}
|
||||
}
|
||||
|
||||
+22
@@ -58,6 +58,21 @@ class BytecodePreloadVerifierServiceTest {
|
||||
assertEquals(BytecodeMarshalingErrorCode.MARSHAL_VERIFY_PRECHECK_UNTERMINATED_FUNCTION, thrown.code());
|
||||
}
|
||||
|
||||
@Test
|
||||
void verifyMustRejectUnknownOpcode() {
|
||||
final var module = new BytecodeModule(
|
||||
0,
|
||||
ReadOnlyList.empty(),
|
||||
ReadOnlyList.from(new BytecodeModule.FunctionMeta(0, 4, 0, 0, 0, 1)),
|
||||
codeUnknownThenRet(),
|
||||
null,
|
||||
ReadOnlyList.empty(),
|
||||
ReadOnlyList.empty());
|
||||
|
||||
final var thrown = assertThrows(BytecodeMarshalingException.class, () -> service.verify(module));
|
||||
assertEquals(BytecodeMarshalingErrorCode.MARSHAL_VERIFY_PRECHECK_UNKNOWN_OPCODE, thrown.code());
|
||||
}
|
||||
|
||||
private byte[] codeHostcall(final int index) {
|
||||
final var out = ByteBuffer.allocate(6).order(ByteOrder.LITTLE_ENDIAN);
|
||||
out.putShort((short) 0x71);
|
||||
@@ -77,4 +92,11 @@ class BytecodePreloadVerifierServiceTest {
|
||||
out.putShort((short) 0x51);
|
||||
return out.array();
|
||||
}
|
||||
|
||||
private byte[] codeUnknownThenRet() {
|
||||
final var out = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN);
|
||||
out.putShort((short) 0x7FFF);
|
||||
out.putShort((short) 0x51);
|
||||
return out.array();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user