libsemanage/backport-libsemanage-fix-asprintf-error-branch.patch
hugel 670213ce64 backport patches from upstream
(cherry picked from commit a6c5156e71001ac8cf1b559ce274e5306006cede)
2025-03-17 17:19:28 +08:00

41 lines
1.2 KiB
Diff

From 44f1323941cd3053e2cd5cdd6995667feca5fb52 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
Date: Mon, 11 Nov 2024 15:16:37 +0100
Subject: [PATCH] libsemanage: fix asprintf error branch
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The content of the first argument after a failure of asprintf(3) is
undefined and must not be used.
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
Conflict:NA
Reference:https://github.com/SELinuxProject/selinux/commit/44f1323941cd3053e2cd5cdd6995667feca5fb52
---
src/boolean_record.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/boolean_record.c b/src/boolean_record.c
index 40dc6545..7878b04d 100644
--- a/src/boolean_record.c
+++ b/src/boolean_record.c
@@ -107,8 +107,10 @@ int semanage_bool_set_name(semanage_handle_t * handle,
end++;
*end = '\0';
rc = asprintf(&newroot, "%s%s%s", prefix, olddir, storename);
- if (rc < 0)
+ if (rc < 0) {
+ newroot = NULL;
goto out;
+ }
if (strcmp(oldroot, newroot)) {
rc = selinux_set_policy_root(newroot);
--
2.33.0