mirror of
https://github.com/openharmony/security_device_auth.git
synced 2026-08-25 09:19:33 -04:00
!275 fix bug when auth next group
Merge pull request !275 from 胡玉/weekly_20220628
This commit is contained in:
@@ -84,27 +84,32 @@ static int32_t StartClientAuthTask(AuthSession *session)
|
||||
return res;
|
||||
}
|
||||
|
||||
static int32_t CheckClientGroupAuthMsg(AuthSession *session, const CJson *in)
|
||||
static bool IsPeerGroupAuthError(const CJson *in)
|
||||
{
|
||||
int32_t groupErrMsg = 0;
|
||||
if (GetIntFromJson(in, FIELD_GROUP_ERROR_MSG, &groupErrMsg) != HC_SUCCESS) {
|
||||
return HC_SUCCESS;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static int32_t DealPeerGroupAuthError(AuthSession *session)
|
||||
{
|
||||
CJson *outData = CreateJson();
|
||||
if (outData == NULL) {
|
||||
LOGE("Failed to malloc for outData!");
|
||||
return HC_ERR_ALLOC_MEMORY;
|
||||
}
|
||||
if (AddIntToJson(outData, FIELD_GROUP_ERROR_MSG, groupErrMsg) != HC_SUCCESS) {
|
||||
LOGE("Failed to add info to outData!");
|
||||
if (AddIntToJson(outData, FIELD_GROUP_ERROR_MSG, GROUP_ERR_MSG) != HC_SUCCESS) {
|
||||
LOGE("Failed to add err msg to outData!");
|
||||
FreeJson(outData);
|
||||
return HC_ERR_JSON_FAIL;
|
||||
}
|
||||
int32_t res = InformAuthError(session, outData, HC_ERR_PEER_ERROR);
|
||||
FreeJson(outData);
|
||||
if (res != HC_SUCCESS) {
|
||||
LOGE("Failed to inform auth error!");
|
||||
}
|
||||
FreeJson(outData);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -136,10 +141,9 @@ static int32_t ProcessClientAuthSession(Session *session, CJson *in)
|
||||
return HC_ERR_NULL_PTR;
|
||||
}
|
||||
ProcessDeviceLevel(in, paramInSession);
|
||||
int32_t res = CheckClientGroupAuthMsg(realSession, in);
|
||||
if (res != HC_SUCCESS) {
|
||||
LOGE("Peer device's group has error, so we stop client auth session!");
|
||||
return res;
|
||||
|
||||
if (IsPeerGroupAuthError(in)) {
|
||||
return DealPeerGroupAuthError(realSession);
|
||||
}
|
||||
CJson *out = CreateJson();
|
||||
if (out == NULL) {
|
||||
@@ -148,7 +152,7 @@ static int32_t ProcessClientAuthSession(Session *session, CJson *in)
|
||||
InformLocalAuthError(paramInSession, realSession->base.callback);
|
||||
return HC_ERR_ALLOC_MEMORY;
|
||||
}
|
||||
res = ProcessClientAuthTask(realSession, GetAuthModuleType(paramInSession), in, out);
|
||||
int32_t res = ProcessClientAuthTask(realSession, GetAuthModuleType(paramInSession), in, out);
|
||||
ClearSensitiveStringInJson(out, FIELD_SESSION_KEY);
|
||||
FreeJson(out);
|
||||
if (res == FINISH) {
|
||||
|
||||
Reference in New Issue
Block a user