Blame SOURCES/0014-libselinux-restorecon-Fix-memory-leak-xattr_value.patch

6a73c2
From 599f1ec818d50ffc9690fea8c03b5fe278f30ed4 Mon Sep 17 00:00:00 2001
6a73c2
From: Vit Mojzis <vmojzis@redhat.com>
6a73c2
Date: Wed, 7 Dec 2022 09:19:29 +0100
6a73c2
Subject: [PATCH] libselinux/restorecon: Fix memory leak - xattr_value
6a73c2
6a73c2
Fix memory leak introduced by commit
6a73c2
 9a04499cebedac3f585c0240e6cf68f786ae62b7
6a73c2
 libselinux: Ignore missing directories when -i is used
6a73c2
6a73c2
Error: RESOURCE_LEAK:
6a73c2
 selinux_restorecon.c:804: alloc_fn: Storage is returned from allocation function "malloc".
6a73c2
 selinux_restorecon.c:804: var_assign: Assigning: "xattr_value" = storage returned from "malloc(fc_digest_len)".
6a73c2
 selinux_restorecon.c:825: leaked_storage: Variable "xattr_value" going out of scope leaks the storage it points to.
6a73c2
6a73c2
Resolves: rhbz#2137965
6a73c2
---
6a73c2
 libselinux/src/selinux_restorecon.c | 2 ++
6a73c2
 1 file changed, 2 insertions(+)
6a73c2
6a73c2
diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c
6a73c2
index 2ff73db6..b3702764 100644
6a73c2
--- a/libselinux/src/selinux_restorecon.c
6a73c2
+++ b/libselinux/src/selinux_restorecon.c
6a73c2
@@ -822,6 +822,7 @@ int selinux_restorecon(const char *pathname_orig,
6a73c2
 				free(basename_cpy);
6a73c2
 				/* missing parent directory */
6a73c2
 				if (flags.ignore_noent && errno == ENOENT) {
6a73c2
+					free(xattr_value);
6a73c2
 					return 0;
6a73c2
 				}
6a73c2
 				goto realpatherr;
6a73c2
@@ -838,6 +839,7 @@ int selinux_restorecon(const char *pathname_orig,
6a73c2
 			if (!pathdnamer) {
6a73c2
 				free(basename_cpy);
6a73c2
 				if (flags.ignore_noent && errno == ENOENT) {
6a73c2
+					free(xattr_value);
6a73c2
 					return 0;
6a73c2
 				}
6a73c2
 				goto realpatherr;
6a73c2
-- 
6a73c2
2.37.3
6a73c2