未验证 提交 7fb8488f 编写于 作者: O openharmony_ci 提交者: Gitee

!951 修复代码静态检查(0719)

Merge pull request !951 from Mupceet/codex
......@@ -31,11 +31,11 @@ static void ProcessPtyWrite(const WatcherHandle taskHandle, int fd, uint32_t *ev
}
CmdAgent *agent = (CmdAgent *)context;
char rbuf[PTY_BUF_SIZE] = {0};
int rlen = read(fd, rbuf, PTY_BUF_SIZE - 1);
ssize_t rlen = read(fd, rbuf, PTY_BUF_SIZE - 1);
int ret = fflush(stdin);
BEGET_ERROR_CHECK(ret == 0, return, "[control_fd] Failed fflush err=%d", errno);
if (rlen > 0) {
int wlen = write(agent->ptyFd, rbuf, rlen);
ssize_t wlen = write(agent->ptyFd, rbuf, rlen);
BEGET_ERROR_CHECK(wlen == rlen, return, "[control_fd] Failed write fifo err=%d", errno);
}
ret = fflush(stdout);
......@@ -51,7 +51,7 @@ static void ProcessPtyRead(const WatcherHandle taskHandle, int fd, uint32_t *eve
}
CmdAgent *agent = (CmdAgent *)context;
char buf[PTY_BUF_SIZE] = {0};
int readlen = read(fd, buf, PTY_BUF_SIZE - 1);
long readlen = read(fd, buf, PTY_BUF_SIZE - 1);
if (readlen > 0) {
fprintf(stdout, "%s", buf);
} else {
......
......@@ -154,14 +154,14 @@ INIT_LOCAL_API const char *GetSerial_(void)
#ifdef LITEOS_SUPPORT
return HalGetSerial();
#else
static char *ohos_serial = NULL;
if (ohos_serial == NULL) {
BEGET_CHECK((ohos_serial = (char *)calloc(1, PARAM_VALUE_LEN_MAX)) != NULL, return NULL);
static char *ohosSerial = NULL;
if (ohosSerial == NULL) {
BEGET_CHECK((ohosSerial = (char *)calloc(1, PARAM_VALUE_LEN_MAX)) != NULL, return NULL);
}
uint32_t len = PARAM_VALUE_LEN_MAX;
int ret = SystemGetParameter("ohos.boot.sn", ohos_serial, &len);
int ret = SystemGetParameter("ohos.boot.sn", ohosSerial, &len);
BEGET_CHECK(ret == 0, return NULL);
return ohos_serial;
return ohosSerial;
#endif
}
......
......@@ -862,6 +862,16 @@ void SetServicePathWithAsan(Service *service)
}
#endif
static void ParseOneServiceArgs(const cJSON *curItem, Service *service)
{
(void)GetServiceArgs(curItem, "writepid", MAX_WRITEPID_FILES, &service->writePidArgs);
(void)GetServiceArgs(curItem, D_CAPS_STR_IN_CFG, MAX_WRITEPID_FILES, &service->capsArgs);
(void)GetServiceArgs(curItem, "permission", MAX_WRITEPID_FILES, &service->permArgs);
(void)GetServiceArgs(curItem, "permission_acls", MAX_WRITEPID_FILES, &service->permAclsArgs);
(void)GetStringItem(curItem, APL_STR_IN_CFG, service->apl, MAX_APL_NAME);
(void)GetCpuArgs(curItem, CPU_CORE_STR_IN_CFG, service);
}
int ParseOneService(const cJSON *curItem, Service *service)
{
INIT_CHECK_RETURN_VALUE(curItem != NULL && service != NULL, SERVICE_FAILURE);
......@@ -899,12 +909,7 @@ int ParseOneService(const cJSON *curItem, Service *service)
ret = GetServiceAttr(curItem, service, CONSOLE_STR_IN_CFG, SERVICE_ATTR_CONSOLE, NULL);
INIT_ERROR_CHECK(ret == 0, return SERVICE_FAILURE, "Failed to get console for service %s", service->name);
(void)GetServiceArgs(curItem, "writepid", MAX_WRITEPID_FILES, &service->writePidArgs);
(void)GetServiceArgs(curItem, D_CAPS_STR_IN_CFG, MAX_WRITEPID_FILES, &service->capsArgs);
(void)GetServiceArgs(curItem, "permission", MAX_WRITEPID_FILES, &service->permArgs);
(void)GetServiceArgs(curItem, "permission_acls", MAX_WRITEPID_FILES, &service->permAclsArgs);
(void)GetStringItem(curItem, APL_STR_IN_CFG, service->apl, MAX_APL_NAME);
(void)GetCpuArgs(curItem, CPU_CORE_STR_IN_CFG, service);
ParseOneServiceArgs(curItem, service);
ret = GetServiceSandbox(curItem, service);
INIT_ERROR_CHECK(ret == 0, return SERVICE_FAILURE, "Failed to get sandbox for service %s", service->name);
ret = GetServiceCaps(curItem, service);
......
......@@ -34,7 +34,7 @@ static int WorkSpaceKeyCompare(const HashNode *node1, const void *key)
return strcmp(workSpace1->fileName, (char *)key);
}
static int GenerateKeyHasCode(const char *buff, uint32_t len)
static int GenerateKeyHasCode(const char *buff, size_t len)
{
int code = 0;
for (size_t i = 0; i < len; i++) {
......
......@@ -52,6 +52,9 @@ static int CheckFilePermission(const ParamSecurityLabel *localLabel, const char
static int DacCheckParamPermission(const ParamSecurityLabel *srcLabel, const char *name, uint32_t mode)
{
UNUSED(srcLabel);
UNUSED(name);
UNUSED(mode);
#if defined(__LITEOS_A__)
uid_t uid = getuid();
return uid <= SYS_UID_INDEX ? DAC_RESULT_PERMISSION : DAC_RESULT_FORBIDED;
......
......@@ -212,6 +212,7 @@ INIT_INNER_API int SysCheckParamExist(const char *name)
INIT_INNER_API int GetParamSecurityAuditData(const char *name, int type, ParamAuditData *auditData)
{
UNUSED(type);
ParamWorkSpace *paramSpace = GetParamWorkSpace();
PARAM_CHECK(paramSpace != NULL, return -1, "Invalid paramSpace");
PARAM_WORKSPACE_CHECK(paramSpace, return -1, "Invalid space");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册