10 Star 3 Fork 16

src-openEuler/libselinux

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-libselinux-add-check-for-calloc-in-check_booleans.patch 945 Bytes
一键复制 编辑 原始数据 按行查看 历史
Huaxin Lu 提交于 2023-07-25 15:04 . add check for calloc in check_booleans
From d8edd363be3184c5738438fde937fd5ebc2d4923 Mon Sep 17 00:00:00 2001
From: Huaxin Lu <luhuaxin1@huawei.com>
Date: Mon, 19 Jun 2023 07:17:02 +0800
Subject: [PATCH] libselinux: add check for calloc in check_booleans
Check the return value of calloc() to avoid null pointer reference.
Signed-off-by: Huaxin Lu <luhuaxin1@huawei.com>
Acked-by: Petr Lautrbach <lautrbach@redhat.com>
---
src/audit2why.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/audit2why.c b/src/audit2why.c
index ba1a66eb..8c4c07d5 100644
--- a/src/audit2why.c
+++ b/src/audit2why.c
@@ -149,6 +149,12 @@ static int check_booleans(struct boolean_t **bools)
if (fcnt > 0) {
*bools = calloc(sizeof(struct boolean_t), fcnt + 1);
+ if (!*bools) {
+ PyErr_SetString( PyExc_MemoryError, "Out of memory\n");
+ free(foundlist);
+ return 0;
+ }
+
struct boolean_t *b = *bools;
for (i = 0; i < fcnt; i++) {
int ctr = foundlist[i];
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/libselinux.git
git@gitee.com:src-openeuler/libselinux.git
src-openeuler
libselinux
libselinux
master

搜索帮助