!241 jit signer 判断逻辑后置

Merge pull request !241 from fundavid/move_checkpoint
This commit is contained in:
openharmony_ci 2024-11-14 11:42:04 +00:00 committed by Gitee
commit 297b4012b6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 8 additions and 2 deletions

View File

@ -204,7 +204,12 @@ __attribute__((no_sanitize("cfi"))) static inline int32_t ResetJitCode(
__attribute__((no_sanitize("cfi"))) static inline int32_t CopyToJitCode(
JitCodeSignerBase *signer, void *jitMemory, void *tmpBuffer, int size)
{
CHECK_NULL_AND_RETURN_CODE(signer);
if (jitMemory == nullptr) {
return CS_ERR_JIT_MEMORY;
}
if (tmpBuffer == nullptr) {
return CS_ERR_TMP_BUFFER;
}
int32_t ret = CS_SUCCESS;
// try not to depend on other dynamic library in JITFORT
#ifndef JIT_FORT_DISABLE
@ -214,6 +219,7 @@ __attribute__((no_sanitize("cfi"))) static inline int32_t CopyToJitCode(
}
#endif
if (IsSupportJitCodeSigner()) {
CHECK_NULL_AND_RETURN_CODE(signer);
ret = signer->ValidateCodeCopy(reinterpret_cast<Instr *>(jitMemory),
reinterpret_cast<Byte *>(tmpBuffer), size);
} else {

View File

@ -694,7 +694,7 @@ HWTEST_F(JitCodeSignTest, JitCodeSignTest_0018, TestSize.Level0)
EXPECT_EQ(PatchInstruction(nullptr, nullptr, 1), CS_ERR_NO_SIGNER);
EXPECT_EQ(PatchData(nullptr, 0, nullptr, 0), CS_ERR_NO_SIGNER);
EXPECT_EQ(PatchData(nullptr, nullptr, nullptr, 0), CS_ERR_NO_SIGNER);
EXPECT_EQ(CopyToJitCode(nullptr, nullptr, nullptr, 0), CS_ERR_NO_SIGNER);
EXPECT_EQ(CopyToJitCode(nullptr, nullptr, nullptr, 0), CS_ERR_JIT_MEMORY);
}
/**