[PATCH 18/47] libsemanage: fix asprintf error branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Christian Göttsche <cgzones@xxxxxxxxxxxxxx>

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@xxxxxxxxxxxxxx>
---
 libsemanage/src/boolean_record.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libsemanage/src/boolean_record.c b/libsemanage/src/boolean_record.c
index 40dc6545..7878b04d 100644
--- a/libsemanage/src/boolean_record.c
+++ b/libsemanage/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.45.2





[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux