From 44f1323941cd3053e2cd5cdd6995667feca5fb52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= 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 Acked-by: James Carter 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