From f9cc77da73a0ad2ebe5998aa3c5509e3ab941510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 1 Dec 2020 12:57:58 +0400 Subject: [PATCH] gio: remove unnecessary strdup and fix potential leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit setfilecon_raw() takes a const argument since libselinux 2.2 (commit https://github.com/SELinuxProject/selinux/commit/6a17cfaafcdab82c9909eccff56968913b36a631) Signed-off-by: Marc-André Lureau --- gio/glocalfileinfo.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c index 32a26d1b2..987ed280e 100644 --- a/gio/glocalfileinfo.c +++ b/gio/glocalfileinfo.c @@ -2715,11 +2715,7 @@ set_selinux_context (char *filename, } if (is_selinux_enabled ()) { - char *val_s; - - val_s = g_strdup (val); - - if (setfilecon_raw (filename, val_s) < 0) + if (setfilecon_raw (filename, val) < 0) { int errsv = errno; @@ -2729,7 +2725,6 @@ set_selinux_context (char *filename, g_strerror (errsv)); return FALSE; } - g_free (val_s); } else { g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, _("SELinux is not enabled on this system"));