提交 58f42481 编写于 作者: O openharmony_ci 提交者: Gitee

!75 静态检查修改

Merge pull request !75 from 熊磊/init07302
......@@ -20,9 +20,11 @@ ohos_static_library("libsocket") {
include_dirs = [
"//base/startup/init_lite/interfaces/innerkits/include",
"//base/startup/init_lite/services/log",
"//third_party/bounds_checking_function/include",
]
deps = [
"//base/startup/init_lite/services/log:init_log",
"//third_party/bounds_checking_function:libsec_static",
]
}
......@@ -28,6 +28,7 @@
#include <sys/uio.h>
#include <sys/un.h>
#include "init_log.h"
#include "securec.h"
#define N_DEC 10
#define MAX_SOCKET_ENV_PREFIX_LEN 64
......@@ -63,7 +64,9 @@ int GetControlSocket(const char *name)
return -1;
}
char path[MAX_SOCKET_ENV_PREFIX_LEN] = {0};
snprintf(path, sizeof(path), OHOS_SOCKET_ENV_PREFIX"%s", name);
if (snprintf_s(path, sizeof(path), sizeof(path) - 1, OHOS_SOCKET_ENV_PREFIX"%s", name) == -1) {
return -1;
}
INIT_LOGI("GetControlSocket path is %s ", path);
int fd = GetControlFromEnv(path);
if (fd < 0) {
......@@ -78,7 +81,9 @@ int GetControlSocket(const char *name)
return -1;
}
char sockDir[MAX_SOCKET_DIR_LEN] = {0};
snprintf(sockDir, sizeof(sockDir), OHOS_SOCKET_DIR"/%s", name);
if (snprintf_s(sockDir, sizeof(sockDir), sizeof(sockDir) - 1, OHOS_SOCKET_DIR"/%s", name) == -1) {
return -1;
}
INIT_LOGI("sockDir %s ", sockDir);
INIT_LOGI("addr.sun_path %s ", addr.sun_path);
if (strncmp(sockDir, addr.sun_path, strlen(sockDir)) == 0) {
......
......@@ -36,8 +36,10 @@ static int SelinuxAuditCallback(void *data,
PARAM_CHECK(auditData != NULL, return PARAM_CODE_INVALID_PARAM, "Invalid param");
PARAM_CHECK(auditData->name != NULL, return PARAM_CODE_INVALID_PARAM, "Invalid param");
PARAM_CHECK(auditData->cr != NULL, return PARAM_CODE_INVALID_PARAM, "Invalid param");
snprintf(msgBuf, msgSize, "param=%s pid=%d uid=%d gid=%d",
auditData->name, auditData->cr->pid, auditData->cr->uid, auditData->cr->gid);
if (snprintf_s(msgBuf, msgSize, msgSize - 1, "param=%s pid=%d uid=%d gid=%d",
auditData->name, auditData->cr->pid, auditData->cr->uid, auditData->cr->gid) == -1) {
return PARAM_CODE_INVALID_PARAM;
}
return 0;
}
#endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册