!356 FUZZ用例crash修复

Merge pull request !356 from 何寅燊/monthly_20221018
This commit is contained in:
openharmony_ci
2022-11-17 04:38:06 +00:00
committed by Gitee
2 changed files with 26 additions and 2 deletions
@@ -18,6 +18,7 @@
#include "device_auth_defines.h"
#include "hc_dev_info.h"
#include "hc_log.h"
#include "hc_types.h"
#include "json_utils.h"
#include "securec.h"
#include <unistd.h>
@@ -61,7 +62,18 @@ namespace OHOS {
InitDeviceAuthService();
const GroupAuthManager *gaInstance = GetGaInstance();
int64_t reqId = 123;
gaInstance->processData(reqId, data, size, &g_gaCallback);
uint8_t *authData = reinterpret_cast<uint8_t *>(HcMalloc(size + 1, 0));
if (authData == nullptr) {
DestroyDeviceAuthService();
return false;
}
if (memcpy_s(authData, size, data, size) != EOK) {
HcFree(authData);
DestroyDeviceAuthService();
return false;
}
gaInstance->processData(reqId, authData, size, &g_gaCallback);
HcFree(authData);
sleep(1);
DestroyDeviceAuthService();
return true;
@@ -18,6 +18,7 @@
#include "device_auth_defines.h"
#include "hc_dev_info.h"
#include "hc_log.h"
#include "hc_types.h"
#include "json_utils.h"
#include "securec.h"
#include <unistd.h>
@@ -63,7 +64,18 @@ namespace OHOS {
const DeviceGroupManager *gmInstance = GetGmInstance();
gmInstance->regCallback(appId.c_str(), &g_gmCallback);
int64_t reqId = 123;
gmInstance->processData(reqId, data, size);
uint8_t *bindData = reinterpret_cast<uint8_t *>(HcMalloc(size + 1, 0));
if (bindData == nullptr) {
DestroyDeviceAuthService();
return false;
}
if (memcpy_s(bindData, size, data, size) != EOK) {
HcFree(bindData);
DestroyDeviceAuthService();
return false;
}
gmInstance->processData(reqId, bindData, size);
HcFree(bindData);
sleep(1);
DestroyDeviceAuthService();
return true;