From 2f3e978f579cca5c1a8feb37c6c9b74776bb53bb Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 7 Sep 2017 15:06:44 +0200 Subject: [PATCH] ifnet: ensure an error is always returned when add fails There are many places where the function can fail without returning an error, leading to a crash. Fix this. --- src/settings/plugins/ifnet/nms-ifnet-plugin.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/settings/plugins/ifnet/nms-ifnet-plugin.c b/src/settings/plugins/ifnet/nms-ifnet-plugin.c index 5a6a8ce83b..faac258768 100644 --- a/src/settings/plugins/ifnet/nms-ifnet-plugin.c +++ b/src/settings/plugins/ifnet/nms-ifnet-plugin.c @@ -321,11 +321,11 @@ add_connection (NMSettingsPlugin *config, * asked to write it to disk. */ if (!ifnet_can_write_connection (source, error)) - return NULL; + goto out; if (save_to_disk) { if (!ifnet_add_new_connection (source, CONF_NET_FILE, WPA_SUPPLICANT_CONF, NULL, NULL, error)) - return NULL; + goto out; reload_connections (config); new = g_hash_table_lookup (priv->connections, nm_connection_get_uuid (source)); } else { @@ -337,6 +337,11 @@ add_connection (NMSettingsPlugin *config, } } +out: + if (!new && error && !*error) { + g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, + "The ifnet plugin cannot add the connection (unknown error)."); + } return (NMSettingsConnection *) new; }