1 Star 0 Fork 31

lujie/libsepol

forked from src-openEuler/libsepol 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-libsepol-reorder-calloc-3-arguments.patch 3.00 KB
一键复制 编辑 原始数据 按行查看 历史
hugel 提交于 2024-03-26 14:02 +08:00 . backport bugfix from upstream
From a0ff05efca3bb04b08a5f5274016d9f1286e9517 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
Date: Fri, 5 Jan 2024 19:35:31 +0100
Subject: [PATCH] libsepol: reorder calloc(3) arguments
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The canonical order of calloc(3) parameters is the number of elements
first and the size of each element second.
Reported by GCC 14:
kernel_to_conf.c:814:47: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
kernel_to_conf.c:945:46: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
kernel_to_conf.c:2109:35: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
kernel_to_common.c:578:29: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
Reference: https://github.com/SELinuxProject/selinux/commit/a0ff05efca3bb04b08a5f5274016d9f1286e9517
Conflict: Context adaptation in kernel_to_common.c.
---
libsepol/src/kernel_to_common.c | 2 +-
libsepol/src/kernel_to_conf.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libsepol/src/kernel_to_common.c b/libsepol/src/kernel_to_common.c
index 4612eef3..2422eed0 100644
--- a/libsepol/src/kernel_to_common.c
+++ b/libsepol/src/kernel_to_common.c
@@ -575,7 +575,7 @@ static int sort_ocontext_data(struct ocontext **ocons, int (*cmp)(const void *,
return 0;
}
- data = calloc(sizeof(*data), num);
+ data = calloc(num, sizeof(*data));
if (!data) {
sepol_log_err("Out of memory\n");
return -1;
diff --git a/libsepol/src/kernel_to_conf.c b/libsepol/src/kernel_to_conf.c
index 83f46e0f..e6b449b4 100644
--- a/libsepol/src/kernel_to_conf.c
+++ b/libsepol/src/kernel_to_conf.c
@@ -811,7 +811,7 @@ static int write_sensitivity_rules_to_conf(FILE *out, struct policydb *pdb)
num = strs_num_items(strs);
if (num > 0) {
- sens_alias_map = calloc(sizeof(*sens_alias_map), pdb->p_levels.nprim);
+ sens_alias_map = calloc(pdb->p_levels.nprim, sizeof(*sens_alias_map));
if (!sens_alias_map) {
rc = -1;
goto exit;
@@ -942,7 +942,7 @@ static int write_category_rules_to_conf(FILE *out, struct policydb *pdb)
num = strs_num_items(strs);
if (num > 0) {
- cat_alias_map = calloc(sizeof(*cat_alias_map), pdb->p_cats.nprim);
+ cat_alias_map = calloc(pdb->p_cats.nprim, sizeof(*cat_alias_map));
if (!cat_alias_map) {
rc = -1;
goto exit;
@@ -2106,7 +2106,7 @@ static int write_cond_nodes_to_conf(FILE *out, struct policydb *pdb)
return 0;
}
- cond_data = calloc(sizeof(struct cond_data), num);
+ cond_data = calloc(num, sizeof(struct cond_data));
if (!cond_data) {
rc = -1;
goto exit;
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lujie42/libsepol.git
git@gitee.com:lujie42/libsepol.git
lujie42
libsepol
libsepol
master

搜索帮助