34 lines
945 B
Diff
34 lines
945 B
Diff
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
|
|
|