fix light auth

Signed-off-by: 郑筝 <zhengzheng16@huawei.com>
This commit is contained in:
郑筝
2025-08-09 19:27:09 +08:00
parent d248486f4f
commit e128bf5526
2 changed files with 18 additions and 5 deletions
+5 -4
View File
@@ -1692,11 +1692,10 @@ static void DestroyLightSessionReturnData(LightSessionReturnData *lightSessionRe
}
HcFree(lightSessionReturnData);
return;
}
static int32_t ProcessLightAccountAuthClient(int64_t requestId, int32_t osAccountId, CJson *msg,
const DeviceAuthCallback *laCallBack, LightSessionReturnData *lightSessionReturnData)
const DeviceAuthCallback *laCallBack, const LightSessionReturnData *lightSessionReturnData)
{
LOGI("ProcessLightAccountAuthClient start!");
CJson *out = CreateJson();
@@ -1753,7 +1752,7 @@ static int32_t LightAuthOnTransmit(int64_t requestId, CJson *out, const DeviceAu
}
static int32_t ProcessLightAccountAuthServer(int64_t requestId, int32_t osAccountId,
CJson *msg, const DeviceAuthCallback *laCallBack, char *returnDataStr)
CJson *msg, const DeviceAuthCallback *laCallBack, const char *returnDataStr)
{
LOGI("ProcessLightAccountAuthServer start!");
CJson *out = CreateJson();
@@ -1770,11 +1769,13 @@ static int32_t ProcessLightAccountAuthServer(int64_t requestId, int32_t osAccoun
CJson *returnDataJson = CreateJsonFromString(returnDataStr);
if (returnDataJson == NULL) {
LOGE("Failed to create json from returnDataStr");
FreeJson(out);
return HC_ERR_JSON_FAIL;
}
const char* serviceId = GetStringFromJson(returnDataJson, FIELD_APP_ID);
if (serviceId == NULL) {
LOGE("Failed to get serviceId");
FreeJson(out);
FreeJson(returnDataJson);
return HC_ERR_JSON_FAIL;
}
@@ -1806,7 +1807,7 @@ static int32_t ProcessLightAccountAuthServer(int64_t requestId, int32_t osAccoun
static int32_t ProcessLightAccountAuthInner(int32_t osAccountId, int64_t requestId,
CJson *msg, CJson *out, const DeviceAuthCallback *laCallBack)
{
LightSessionReturnData *lightSessionReturnData =
LightSessionReturnData *lightSessionReturnData =
(LightSessionReturnData *)HcMalloc(sizeof(LightSessionReturnData), 0);
if (lightSessionReturnData == NULL) {
LOGE("Failed to alloc lightSessionReturnData");
@@ -159,15 +159,27 @@ int32_t QueryLightSession(int64_t requestId, int32_t osAccountId, uint8_t **rand
}
if (requestId == entry->session->requestId && osAccountId == entry->session->osAccountId) {
*randomVal = (uint8_t *)HcMalloc(entry->session->randomLen, 0);
if (*randomVal == NULL) {
LOGE("Malloc randomVal failed.");
return HC_ERR_MEMORY_COPY;
}
if (memcpy_s(*randomVal, entry->session->randomLen, entry->session->randomVal,
entry->session->randomLen) != EOK) {
entry->session->randomLen) != EOK) {
HcFree(*randomVal);
LOGE("Copy randomVal failed.");
return HC_ERR_MEMORY_COPY;
}
uint32_t serviceIdLen = (uint32_t)HcStrlen(entry->session->serviceId);
*serviceId = (char *)HcMalloc(serviceIdLen, 0);
if (*serviceId == NULL) {
HcFree(*randomVal);
LOGE("Malloc serviceId failed.");
return HC_ERR_MEMORY_COPY;
}
if (memcpy_s(*serviceId, serviceIdLen, entry->session->serviceId,
serviceIdLen) != EOK) {
HcFree(*randomVal);
HcFree(*serviceId);
LOGE("Copy serviceId failed.");
return HC_ERR_MEMORY_COPY;
}