Blame SOURCES/0004-service-do-not-copy-option-values-to-avoid-memory-le.patch

cd9052
From 7daf5993995baad0f5c7f7ae3822dae37eb9f46f Mon Sep 17 00:00:00 2001
cd9052
From: Sumit Bose <sbose@redhat.com>
cd9052
Date: Fri, 30 Oct 2020 16:44:23 +0100
cd9052
Subject: [PATCH 4/6] service: do not copy option values to avoid memory leaks
cd9052
cd9052
---
cd9052
 service/realm-adcli-enroll.c | 15 ++++++++-------
cd9052
 service/realm-options.c      |  8 +++-----
cd9052
 2 files changed, 11 insertions(+), 12 deletions(-)
cd9052
cd9052
diff --git a/service/realm-adcli-enroll.c b/service/realm-adcli-enroll.c
cd9052
index 2731283..e0d752b 100644
cd9052
--- a/service/realm-adcli-enroll.c
cd9052
+++ b/service/realm-adcli-enroll.c
cd9052
@@ -80,7 +80,8 @@ realm_adcli_enroll_join_async (RealmDisco *disco,
cd9052
 	GBytes *input = NULL;
cd9052
 	const gchar *upn;
cd9052
 	GPtrArray *args;
cd9052
-	const gchar *os;
cd9052
+	const gchar *os_n = NULL;
cd9052
+	const gchar *os_v = NULL;
cd9052
 	gchar *ccache_arg = NULL;
cd9052
 	gchar *upn_arg = NULL;
cd9052
 	gchar *server_arg = NULL;
cd9052
@@ -144,16 +145,16 @@ realm_adcli_enroll_join_async (RealmDisco *disco,
cd9052
 			g_ptr_array_add (args, (gpointer)computer_ou);
cd9052
 	}
cd9052
 
cd9052
-	os = realm_options_ad_specific (options, "os-name");
cd9052
-	if (os != NULL && !g_str_equal (os, "")) {
cd9052
+	os_n = realm_options_ad_specific (options, "os-name");
cd9052
+	if (os_n != NULL && !g_str_equal (os_n, "")) {
cd9052
 		g_ptr_array_add (args, "--os-name");
cd9052
-		g_ptr_array_add (args, (gpointer)os);
cd9052
+		g_ptr_array_add (args, (gpointer)os_n);
cd9052
 	}
cd9052
 
cd9052
-	os = realm_options_ad_specific (options, "os-version");
cd9052
-	if (os != NULL && !g_str_equal (os, "")) {
cd9052
+	os_v = realm_options_ad_specific (options, "os-version");
cd9052
+	if (os_v != NULL && !g_str_equal (os_v, "")) {
cd9052
 		g_ptr_array_add (args, "--os-version");
cd9052
-		g_ptr_array_add (args, (gpointer)os);
cd9052
+		g_ptr_array_add (args, (gpointer)os_v);
cd9052
 	}
cd9052
 
cd9052
 	switch (cred->type) {
cd9052
diff --git a/service/realm-options.c b/service/realm-options.c
cd9052
index d42eb7c..4ebd6c0 100644
cd9052
--- a/service/realm-options.c
cd9052
+++ b/service/realm-options.c
cd9052
@@ -179,7 +179,7 @@ realm_options_computer_name (GVariant *options,
cd9052
 		g_free (section);
cd9052
 	}
cd9052
 
cd9052
-	return g_strdup (computer_name);
cd9052
+	return computer_name;
cd9052
 }
cd9052
 
cd9052
 const gchar *
cd9052
@@ -197,22 +197,20 @@ realm_options_ad_specific (GVariant *options,
cd9052
 		value = realm_settings_value ("active-directory", option_name);
cd9052
 	}
cd9052
 
cd9052
-	return g_strdup (value);
cd9052
+	return value;
cd9052
 }
cd9052
 
cd9052
 gboolean realm_option_use_ldaps (GVariant *options)
cd9052
 {
cd9052
-	gchar *use_ldaps_str;
cd9052
+	const gchar *use_ldaps_str;
cd9052
 
cd9052
 	use_ldaps_str = realm_options_ad_specific (options,
cd9052
 	                                          REALM_DBUS_OPTION_USE_LDAPS);
cd9052
 	if (use_ldaps_str != NULL
cd9052
 	            && ( g_ascii_strcasecmp (use_ldaps_str, "True") == 0
cd9052
 	                || g_ascii_strcasecmp (use_ldaps_str, "Yes") == 0)) {
cd9052
-		g_free (use_ldaps_str);
cd9052
 		return TRUE;
cd9052
 	}
cd9052
-	g_free (use_ldaps_str);
cd9052
 
cd9052
 	return FALSE;
cd9052
 }
cd9052
-- 
cd9052
2.26.2
cd9052