mirror of
https://gitee.com/openharmony/useriam_user_auth_framework
synced 2024-11-30 03:11:25 +00:00
fix fuzz problem
Signed-off-by: youliang_1314 <youliang4@huawei.com> Change-Id: I8efcaf7e69d51ced15b7015f38689412928690f7
This commit is contained in:
parent
c4fabc801a
commit
c55d52f562
@ -251,7 +251,8 @@ ResultCode FrameworkExecutorCallback::ProcessGetTemplateCommand(
|
||||
TemplateInfo templateInfo = {};
|
||||
ResultCode ret = hdi->GetTemplateInfo(templateId, templateInfo);
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(ret == SUCCESS, ret);
|
||||
int32_t subType = *(static_cast<int32_t *>(static_cast<void *>(templateInfo.extraInfo.data())));
|
||||
int32_t subType = 0;
|
||||
Common::UnpackInt32(templateInfo.extraInfo, 0, subType);
|
||||
bool setAuthSubTypeRet = values->SetInt32Value(Attributes::ATTR_PIN_SUB_TYPE, subType);
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(setAuthSubTypeRet == true, ResultCode::GENERAL_ERROR);
|
||||
bool setAuthRemainTimeRet =
|
||||
|
@ -36,6 +36,17 @@ int32_t UnpackUint64(const std::vector<uint8_t> &src, size_t index, uint64_t &da
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t UnpackInt32(const std::vector<uint8_t> &src, size_t index, int32_t &data)
|
||||
{
|
||||
if ((src.size() < index) || (src.size() - index < sizeof(int32_t))) {
|
||||
return 1;
|
||||
}
|
||||
if (memcpy_s(static_cast<void *>(&data), sizeof(int32_t), &src[index], sizeof(int32_t)) != 0) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
} // namespace Common
|
||||
} // namespace UserIam
|
||||
} // namespace OHOS
|
@ -30,6 +30,7 @@ inline void Pack(std::vector<uint8_t> &dst, const T &data)
|
||||
}
|
||||
|
||||
int32_t UnpackUint64(const std::vector<uint8_t> &src, size_t index, uint64_t &data);
|
||||
int32_t UnpackInt32(const std::vector<uint8_t> &src, size_t index, int32_t &data);
|
||||
|
||||
inline uint32_t CombineUint16ToUint32(uint16_t upper, uint16_t lower)
|
||||
{
|
||||
|
@ -850,7 +850,7 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnGetPropertyTest_001, TestSize.Leve
|
||||
static const uint64_t testTemplateId = 123;
|
||||
static const int32_t testFreezingTime = 456;
|
||||
static const int32_t testRemainTimes = 789;
|
||||
static const uint64_t testAuthSubType = 101112;
|
||||
static const int32_t testAuthSubType = 101112;
|
||||
|
||||
shared_ptr<Executor> executor;
|
||||
shared_ptr<ExecutorRegisterCallback> executorCallback;
|
||||
@ -865,7 +865,7 @@ HWTEST_F(ExecutorUnitTest, UserAuthExecutor_OnGetPropertyTest_001, TestSize.Leve
|
||||
EXPECT_EQ(templateId, testTemplateId);
|
||||
info.freezingTime = testFreezingTime;
|
||||
info.remainTimes = testRemainTimes;
|
||||
Common::Pack<uint64_t>(info.extraInfo, testAuthSubType);
|
||||
Common::Pack<int32_t>(info.extraInfo, testAuthSubType);
|
||||
return ResultCode::SUCCESS;
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user