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] c7d197477c/properties/nm-vpnc-editor-plugin.c (L281)

(cherry picked from commit 3b2eb689f3)
This commit is contained in:
Thomas Haller 2022-11-16 13:05:52 +01:00
parent 4e857e33fc
commit 3e9b5217f3
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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);
}