diff --git a/include/appspawn_message.h b/include/appspawn_message.h index 6edd3b38a57e076317c188e7ec0211fd1a53e3f9..8fb547fea66c7157b3378d9c3612d604a10efec3 100755 --- a/include/appspawn_message.h +++ b/include/appspawn_message.h @@ -24,7 +24,7 @@ extern "C" { typedef struct { char* bundleName; char* sharedLibPaths; - unsigned long long identityID; + char* identityID; int uID; int gID; } MessageSt; diff --git a/src/appspawn_message.c b/src/appspawn_message.c index f0741f47e7526d18722c42229bd957f09b54e834..d06c980370dfe93f69ec5a9c21cb1c5640a2dd27 100755 --- a/src/appspawn_message.c +++ b/src/appspawn_message.c @@ -32,6 +32,8 @@ static const size_t MAX_BUNDLE_NAME_LEN = 127; static const size_t MIN_BUNDLE_NAME_LEN = 7; static const size_t MAX_SHARED_LIB_PATH_LEN = 2048; static const size_t MIN_SHARED_LIB_PATH_LEN = 0; +static const size_t MAX_IDENTITY_ID_LEN = 24; +static const size_t MIN_IDENTITY_ID_LEN = 1; void FreeMessageSt(MessageSt* targetSt) { @@ -46,7 +48,11 @@ void FreeMessageSt(MessageSt* targetSt) targetSt->sharedLibPaths = NULL; } - targetSt->identityID = 0; + if (targetSt->identityID != NULL) { + free(targetSt->identityID); + targetSt->identityID = NULL; + } + targetSt->uID = -1; targetSt->gID = -1; } @@ -120,16 +126,20 @@ int SplitMessage(const char* msg, unsigned int msgLen, MessageSt* msgSt) } cJSON* identityIDItem = cJSON_GetObjectItem(rootJ, "identityID"); + ret = ReadStringItem(identityIDItem, &(msgSt->identityID), MAX_IDENTITY_ID_LEN, MIN_IDENTITY_ID_LEN); + if (ret != EC_SUCCESS) { + FreeMessageSt(msgSt); + cJSON_Delete(rootJ); + return ret; + } + cJSON* uIDItem = cJSON_GetObjectItem(rootJ, "uID"); cJSON* gIDItem = cJSON_GetObjectItem(rootJ, "gID"); - - msgSt->identityID = (unsigned long long)ReadNumberItem(identityIDItem); msgSt->uID = (int)ReadNumberItem(uIDItem); msgSt->gID = (int)ReadNumberItem(gIDItem); cJSON_Delete(rootJ); - if (msgSt->identityID == 0 || msgSt->uID <= 0 || msgSt->gID <= 0 || - msgSt->identityID == ULLONG_MAX || msgSt->uID == INT_MAX || msgSt->gID == INT_MAX) { + if (msgSt->uID <= 0 || msgSt->gID <= 0 || msgSt->uID == INT_MAX || msgSt->gID == INT_MAX) { FreeMessageSt(msgSt); return EC_PROTOCOL; } diff --git a/src/appspawn_process.c b/src/appspawn_process.c index 902837f159e88181a8c2c76eab939a4c5adc542b..31f0312c1467ea409b3976149513ec44d986364a 100755 --- a/src/appspawn_process.c +++ b/src/appspawn_process.c @@ -126,9 +126,9 @@ pid_t CreateProcess(const MessageSt* msgSt) return -1; } - if (sprintf_s(identityIDStr, MAX_IDENTITY_ID_LENGTH, "%llu", msgSt->identityID) <= 0 || + if (sprintf_s(identityIDStr, MAX_IDENTITY_ID_LENGTH, "%s", msgSt->identityID) <= 0 || sprintf_s(processNameStr, MAX_PROCESS_NAME_LENGTH, "%s", msgSt->bundleName) <= 0) { - HILOG_ERROR(HILOG_MODULE_HIVIEW, "[appspawn] sprintf_s failed. id %{public}llu, name %{public}s.",\ + HILOG_ERROR(HILOG_MODULE_HIVIEW, "[appspawn] sprintf_s failed. id %{public}s, name %{public}s.",\ msgSt->identityID, msgSt->bundleName); return -1; } diff --git a/src/appspawn_service.c b/src/appspawn_service.c index 70dd9a289187d7a152aeafbee82e47ed7fbd6f66..3415d9ab2489b70764ffdd9e94bcf9bd25dc335a 100755 --- a/src/appspawn_service.c +++ b/src/appspawn_service.c @@ -119,7 +119,7 @@ static int Invoke(IServerProxy* iProxy, int funcId, void* origin, IpcIo* req, Ip return EC_FAILURE; } - HILOG_INFO(HILOG_MODULE_HIVIEW, "[appspawn] msg<%{public}s,%{public}s,%{public}llu,%{public}d,%{public}d>",\ + HILOG_INFO(HILOG_MODULE_HIVIEW, "[appspawn] msg<%{public}s,%{public}s,%{public}s,%{public}d,%{public}d>",\ msgSt.bundleName, msgSt.sharedLibPaths, msgSt.identityID, msgSt.uID, msgSt.gID); pid_t newPid = CreateProcess(&msgSt);