summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2017-01-24 10:09:34 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2017-01-24 10:11:01 +0100
commiteca461a2141c0e0942ab0e74e5922a329fe113a4 (patch)
tree2ee0c2fac97745b8228d9994846e091bb974ff2d
parentb203183ff3ef946b6f8fdd24cfae9f0a5cb25cd9 (diff)
downloadnetwork-manager-applet-eca461a2141c0e0942ab0e74e5922a329fe113a4.tar.gz
editor: don't leak the cloned MAC string
Fixes: 85b6b659a140a59c3df787062e089a0b4e2a547d
-rw-r--r--src/connection-editor/ce-page.c9
-rw-r--r--src/connection-editor/ce-page.h2
-rw-r--r--src/connection-editor/page-ethernet.c3
-rw-r--r--src/connection-editor/page-vlan.c3
-rw-r--r--src/connection-editor/page-wifi.c3
5 files changed, 13 insertions, 7 deletions
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c
index f88dce0c..5ba6ca99 100644
--- a/src/connection-editor/ce-page.c
+++ b/src/connection-editor/ce-page.c
@@ -319,14 +319,14 @@ ce_page_setup_cloned_mac_combo (GtkComboBoxText *combo, const char *current)
}
}
-const char *
+char *
ce_page_cloned_mac_get (GtkComboBoxText *combo)
{
const char *id;
id = gtk_combo_box_get_active_id (GTK_COMBO_BOX (combo));
if (id)
- return id;
+ return g_strdup (id);
return gtk_combo_box_text_get_active_text (combo);
}
@@ -358,10 +358,13 @@ mac_valid (const char *mac, int type, const char *property_name, GError **error)
gboolean
ce_page_cloned_mac_combo_valid (GtkComboBoxText *combo, int type, const char *property_name, GError **error)
{
+ gs_free char *text = NULL;
+
if (gtk_combo_box_get_active (GTK_COMBO_BOX (combo)) != -1)
return TRUE;
- return mac_valid (gtk_combo_box_text_get_active_text (combo),
+ text = gtk_combo_box_text_get_active_text (combo);
+ return mac_valid (text,
type,
property_name,
error);
diff --git a/src/connection-editor/ce-page.h b/src/connection-editor/ce-page.h
index e869bb69..5cd1c3df 100644
--- a/src/connection-editor/ce-page.h
+++ b/src/connection-editor/ce-page.h
@@ -150,7 +150,7 @@ gboolean ce_page_device_entry_get (GtkEntry *entry, int type,
char **ifname, char **mac,
const char *device_name,
GError **error);
-const char *ce_page_cloned_mac_get (GtkComboBoxText *combo);
+char *ce_page_cloned_mac_get (GtkComboBoxText *combo);
gboolean ce_page_cloned_mac_combo_valid (GtkComboBoxText *combo, int type, const char *property_name, GError **error);
void ce_page_changed (CEPage *self);
diff --git a/src/connection-editor/page-ethernet.c b/src/connection-editor/page-ethernet.c
index fbdafaac..f41b2783 100644
--- a/src/connection-editor/page-ethernet.c
+++ b/src/connection-editor/page-ethernet.c
@@ -385,7 +385,7 @@ ui_to_setting (CEPageEthernet *self)
const char *duplex;
char *ifname = NULL;
char *device_mac = NULL;
- const char *cloned_mac;
+ char *cloned_mac;
GtkWidget *entry;
NMSettingWiredWakeOnLan wol = NM_SETTING_WIRED_WAKE_ON_LAN_NONE;
const char *wol_passwd = NULL;
@@ -500,6 +500,7 @@ ui_to_setting (CEPageEthernet *self)
g_free (ifname);
g_free (device_mac);
+ g_free (cloned_mac);
}
static gboolean
diff --git a/src/connection-editor/page-vlan.c b/src/connection-editor/page-vlan.c
index 6806d8b1..79c294c6 100644
--- a/src/connection-editor/page-vlan.c
+++ b/src/connection-editor/page-vlan.c
@@ -618,7 +618,7 @@ ui_to_setting (CEPageVlan *self)
CEPageVlanPrivate *priv = CE_PAGE_VLAN_GET_PRIVATE (self);
NMConnection *connection = CE_PAGE (self)->connection;
NMSettingConnection *s_con = nm_connection_get_setting_connection (connection);
- const char *cloned_mac;
+ char *cloned_mac;
VlanParent *parent = NULL;
int active_id, parent_id, vid;
const char *parent_iface = NULL, *parent_uuid = NULL;
@@ -718,6 +718,7 @@ ui_to_setting (CEPageVlan *self)
}
g_free (tmp_parent_iface);
+ g_free (cloned_mac);
}
static gboolean
diff --git a/src/connection-editor/page-wifi.c b/src/connection-editor/page-wifi.c
index f97365dc..fad89e74 100644
--- a/src/connection-editor/page-wifi.c
+++ b/src/connection-editor/page-wifi.c
@@ -485,7 +485,7 @@ ui_to_setting (CEPageWifi *self)
const char *bssid = NULL;
char *ifname = NULL;
char *device_mac = NULL;
- const char *cloned_mac;
+ char *cloned_mac;
const char *mode;
const char *band;
GtkWidget *entry;
@@ -548,6 +548,7 @@ ui_to_setting (CEPageWifi *self)
g_bytes_unref (ssid);
g_free (ifname);
g_free (device_mac);
+ g_free (cloned_mac);
}
static gboolean