12 Star 0 Fork 13

src-openEuler/checkpolicy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-checkpolicy-check-identifier-before-copying.patch 1.39 KB
一键复制 编辑 原始数据 按行查看 历史
wjiang 提交于 2025-03-14 14:45 +08:00 . backport patches from upstream
From 158fb95ef28af13ccc8a6f1474aaa2e69620afd0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
Date: Wed, 15 Jan 2025 14:13:25 +0100
Subject: [PATCH] checkpolicy: check identifier before copying
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Avoid calling strdup(3) with a NULL pointer, which can happen with an
invalid policy context, e.g.:
class C
sid S
class C { P }
;
user U roles j;
sid S s:l:q:q:q
Fixes: 6f2b689f ("checkpolicy: Fix MLS users in optional blocks")
Reported-by: oss-fuzz (issue 390004173)
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
policy_define.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/policy_define.c b/policy_define.c
index 2f811b67..96a481f7 100644
--- a/policy_define.c
+++ b/policy_define.c
@@ -4411,6 +4411,7 @@ static int parse_semantic_categories(char *id, level_datum_t * levdatum __attrib
int define_user(void)
{
+ const char *username;
char *id;
user_datum_t *usrdatum, *usr_global;
level_datum_t *levdatum;
@@ -4437,7 +4438,13 @@ int define_user(void)
return 0;
}
- id = strdup(queue_head(id_queue));
+ username = queue_head(id_queue);
+ if (!username) {
+ yyerror("no user name");
+ return -1;
+ }
+
+ id = strdup(username);
if ((usrdatum = declare_user()) == NULL) {
free(id);
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/checkpolicy.git
git@gitee.com:src-openeuler/checkpolicy.git
src-openeuler
checkpolicy
checkpolicy
master

搜索帮助