!662 【安全libfuzz】DeviceManagerServiceFuzzTest用例执行结果异常

Merge pull request !662 from 王移波/master
This commit is contained in:
openharmony_ci
2022-07-14 08:34:31 +00:00
committed by Gitee
3 changed files with 24 additions and 0 deletions
+3
View File
@@ -49,6 +49,9 @@ const int32_t DISCOVER_STATUS_LEN = 20;
const int32_t COMMON_CALLBACK_MAX_SIZE = 200;
const uint32_t MAX_LOAD_VALUE = 3;
const int32_t DM_AUTH_TYPE_MAX = 4;
const int32_t DM_AUTH_TYPE_MIN = 1;
enum {
DM_OK = 0,
ERR_DM_FAILED = -20000,
@@ -61,7 +61,20 @@ int32_t DmAuthManager::AuthenticateDevice(const std::string &pkgName, int32_t au
const std::string &extra)
{
LOGI("DmAuthManager::AuthenticateDevice start auth type %d", authType);
if (authType < DM_AUTH_TYPE_MIN || authType > DM_AUTH_TYPE_MAX) {
LOGE("AuthenticateDevice failed, authType is illegal");
return ERR_DM_AUTH_FAILED;
}
if (pkgName.empty() || deviceId.empty() || extra.empty()) {
LOGE("DmAuthManager::AuthenticateDevice failed, pkgName is %s, deviceId is %s, extra is %s",
pkgName.c_str(), deviceId.c_str(), extra.c_str());
return ERR_DM_INPUT_PARAMETER_EMPTY;
}
std::shared_ptr<IAuthentication> authentication = authenticationMap_[authType];
if (listener_ == nullptr) {
LOGE("DmAuthManager::AuthenticateDevice is empty nullptr");
return ERR_DM_INPUT_PARAMETER_EMPTY;
}
if (authentication == nullptr) {
LOGE("DmAuthManager::AuthenticateDevice authType %d not support.", authType);
listener_->OnAuthResult(pkgName, deviceId, "", AuthState::AUTH_REQUEST_INIT, ERR_DM_UNSUPPORTED_AUTH_TYPE);
@@ -167,6 +167,14 @@ int32_t DeviceManagerServiceImpl::AuthenticateDevice(const std::string &pkgName,
LOGE("AuthenticateDevice failed, deviceId is empty");
return ERR_DM_INPUT_PARAMETER_EMPTY;
}
if (authType < DM_AUTH_TYPE_MIN || authType > DM_AUTH_TYPE_MAX) {
LOGE("AuthenticateDevice failed, authType is illegal");
return ERR_DM_AUTH_FAILED;
}
if (extra.empty()) {
LOGE("AuthenticateDevice failed, extra is empty");
return ERR_DM_INPUT_PARAMETER_EMPTY;
}
return authMgr_->AuthenticateDevice(pkgName, authType, deviceId, extra);
}