33ada68674
Rebase on upstream f56a72ac9e86
38 lines
1.2 KiB
Diff
38 lines
1.2 KiB
Diff
From c916f0884bd08b99ddc77b6a148a730d107a9979 Mon Sep 17 00:00:00 2001
|
|
From: Juraj Marcin <juraj@jurajmarcin.com>
|
|
Date: Mon, 29 Aug 2022 14:28:40 +0200
|
|
Subject: [PATCH] checkpolicy: avoid passing NULL pointer to memset()
|
|
Content-type: text/plain
|
|
|
|
Function `class_perm_node_init()` is called with `dest_perms` before it
|
|
is checked that its allocation succeeded. If the allocation fails, then
|
|
a NULL pointer is passed to `memset()` inside the
|
|
`class_perm_node_init()` function.
|
|
|
|
Signed-off-by: Juraj Marcin <juraj@jurajmarcin.com>
|
|
---
|
|
checkpolicy/policy_define.c | 3 ++-
|
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/checkpolicy/policy_define.c b/checkpolicy/policy_define.c
|
|
index f3b4887021c1..54bb304b331f 100644
|
|
--- a/checkpolicy/policy_define.c
|
|
+++ b/checkpolicy/policy_define.c
|
|
@@ -2371,11 +2371,12 @@ static int avrule_cpy(avrule_t *dest, const avrule_t *src)
|
|
src_perms = src->perms;
|
|
while (src_perms) {
|
|
dest_perms = (class_perm_node_t *) calloc(1, sizeof(class_perm_node_t));
|
|
- class_perm_node_init(dest_perms);
|
|
if (!dest_perms) {
|
|
yyerror("out of memory");
|
|
return -1;
|
|
}
|
|
+ class_perm_node_init(dest_perms);
|
|
+
|
|
if (!dest->perms)
|
|
dest->perms = dest_perms;
|
|
else
|
|
--
|
|
2.38.1
|
|
|