summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-11-16 13:05:52 +0100
committerThomas Haller <thaller@redhat.com>2022-11-16 13:05:55 +0100
commit3b2eb689f3da1e957216b6106382b9a46bae266f (patch)
tree67b07ec6f5fbd56acb1edd78e935c5084fc7eddf
parent8d6cba655574e25d8a08c58e87c9dbd8e6a1bc23 (diff)
downloadNetworkManager-3b2eb689f3da1e957216b6106382b9a46bae266f.tar.gz
libnm: workaround crash in nm_vpn_editor_plugin_import() for plugin requiring GError
The "GError **error" parameter in GLib API should be optional. Due to a bug in at least nm-vpnc ([1]), this is not the case. Workaround in libnm. [1] https://gitlab.gnome.org/GNOME/NetworkManager-vpnc/-/blob/c7d197477c94c5bae0396f0ef826db4d835e487d/properties/nm-vpnc-editor-plugin.c#L281
-rw-r--r--src/libnm-core-impl/nm-vpn-editor-plugin.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libnm-core-impl/nm-vpn-editor-plugin.c b/src/libnm-core-impl/nm-vpn-editor-plugin.c
index 225f25ef22..3a6abbc2ad 100644
--- a/src/libnm-core-impl/nm-vpn-editor-plugin.c
+++ b/src/libnm-core-impl/nm-vpn-editor-plugin.c
@@ -470,8 +470,20 @@ nm_vpn_editor_plugin_import(NMVpnEditorPlugin *plugin, const char *path, GError
g_return_val_if_fail(NM_IS_VPN_EDITOR_PLUGIN(plugin), NULL);
if (nm_vpn_editor_plugin_get_capabilities(plugin) & NM_VPN_EDITOR_PLUGIN_CAPABILITY_IMPORT) {
+ gs_free_error GError *error2 = NULL;
+
g_return_val_if_fail(NM_VPN_EDITOR_PLUGIN_GET_INTERFACE(plugin)->import_from_file != NULL,
NULL);
+
+ if (!error) {
+ /* Some VPN plugins crash if error argument is omitted. Work around that
+ * in libnm by always requesting an error.
+ *
+ * https://gitlab.gnome.org/GNOME/NetworkManager-vpnc/-/blob/c7d197477c94c5bae0396f0ef826db4d835e487d/properties/nm-vpnc-editor-plugin.c#L281
+ **/
+ error = &error2;
+ }
+
return NM_VPN_EDITOR_PLUGIN_GET_INTERFACE(plugin)->import_from_file(plugin, path, error);
}