diff --git a/services/param/adapter/param_selinux.c b/services/param/adapter/param_selinux.c index f29836d711106ba2ebb438478b98c6e2f36685a8..919ae1d7d66b755603ca3ec99ef65e329e82b02f 100644 --- a/services/param/adapter/param_selinux.c +++ b/services/param/adapter/param_selinux.c @@ -136,8 +136,9 @@ static uint32_t GetWorkSpaceSize(const char *content) return PARAM_WORKSPACE_MAX; } char name[PARAM_NAME_LEN_MAX] = {0}; + int index = 6; // 6 strlen for const. + (void)ParamMemcpy(name, sizeof(name), "const.", index); size_t len = strlen(content); - int index = 0; for (size_t i = strlen("u:object_r:"); i < len; i++) { if (*(content + i) == ':') { break; diff --git a/services/param/base/param_trie.c b/services/param/base/param_trie.c index 9f05a3f6dad2ab936a7f9b0c8aefbd15ab4afc81..dea6832ec01292039d8d007f74f60015a34d149a 100644 --- a/services/param/base/param_trie.c +++ b/services/param/base/param_trie.c @@ -342,7 +342,11 @@ INIT_LOCAL_API ParamNode *GetParamNode(uint32_t index, const char *name) INIT_LOCAL_API int AddParamEntry(uint32_t index, uint8_t type, const char *name, const char *value) { WorkSpace *workSpace = GetWorkSpace(WORKSPACE_INDEX_BASE); - ParamTrieNode *node = AddTrieNode(workSpace, name, strlen(name)); + ParamTrieNode *node = FindTrieNode(workSpace, name, strlen(name), NULL); + if (node != NULL && node->dataIndex != 0) { + return 0; + } + node = AddTrieNode(workSpace, name, strlen(name)); PARAM_CHECK(node != NULL, return PARAM_CODE_REACHED_MAX, "Failed to add node"); ParamNode *entry = (ParamNode *)GetTrieNode(workSpace, node->dataIndex); if (entry == NULL) { diff --git a/services/param/manager/param_server.c b/services/param/manager/param_server.c index 2884ea9e6fd773006ffae5bc9af84ac952c2bdb5..e8e3908553469507554b156ce24102fb824954f3 100755 --- a/services/param/manager/param_server.c +++ b/services/param/manager/param_server.c @@ -256,10 +256,14 @@ static int LoadOneParamAreaSize_(const uint32_t *context, const char *name, cons ret = CheckParamValue(NULL, name, value, PARAM_TYPE_INT); PARAM_CHECK(ret == 0, return 0, "Invalid value %s for %s", value, name); PARAM_LOGV("LoadOneParamAreaSize_ [%s] [%s]", name, value); - return AddParamEntry(WORKSPACE_INDEX_BASE, PARAM_TYPE_INT, name, value); + char buffer[PARAM_NAME_LEN_MAX] = {0}; + int len = sprintf_s(buffer, sizeof(buffer), "const.%s", name); + PARAM_CHECK(len > 0, return 0, "Failed to format value %s for %s", value, name); + return AddParamEntry(WORKSPACE_INDEX_BASE, PARAM_TYPE_INT, buffer, value); } INIT_LOCAL_API void LoadParamAreaSize(void) { + LoadDefaultParam_("/sys_prod/etc/param/ohos.para.size", 0, NULL, 0, LoadOneParamAreaSize_); LoadDefaultParam_(PARAM_AREA_SIZE_CFG, 0, NULL, 0, LoadOneParamAreaSize_); }