mirror of
https://github.com/openharmony/startup_appspawn_lite.git
synced 2026-07-18 17:34:32 -04:00
!1 【轻量级 PR】:Modify the identityID field type to string
Merge pull request !1 from 张阿龙/N/A
This commit is contained in:
@@ -24,7 +24,7 @@ extern "C" {
|
||||
typedef struct {
|
||||
char* bundleName;
|
||||
char* sharedLibPaths;
|
||||
unsigned long long identityID;
|
||||
char* identityID;
|
||||
int uID;
|
||||
int gID;
|
||||
} MessageSt;
|
||||
|
||||
+15
-5
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user