clients,vpn: only accept full service-types in nm_vpn_get_secret_names()

nm_vpn_get_secret_names() has only one caller, which passes
nm_setting_vpn_get_service_type() as @vpn_type argument. That
argument is not a short-name or abbreviation, it must be the
full service-type.

For our well-known, hard-coded list of service-types, all must
start with the same prefix.
This commit is contained in:
Thomas Haller 2016-06-20 19:02:40 +02:00
parent 59269b6925
commit 7e0660bf07

View file

@ -135,11 +135,13 @@ nm_vpn_get_secret_names (const char *vpn_type)
if (!vpn_type)
return NULL;
if (g_str_has_prefix (vpn_type, NM_DBUS_INTERFACE))
type = vpn_type + strlen (NM_DBUS_INTERFACE) + 1;
else
type = vpn_type;
if ( !g_str_has_prefix (vpn_type, NM_DBUS_INTERFACE)
|| vpn_type[NM_STRLEN (NM_DBUS_INTERFACE)] != '.') {
/* all our well-known, hard-coded vpn-types start with NM_DBUS_INTERFACE. */
return NULL;
}
type = vpn_type + (NM_STRLEN (NM_DBUS_INTERFACE) + 1);
if ( !g_strcmp0 (type, "pptp")
|| !g_strcmp0 (type, "iodine")
|| !g_strcmp0 (type, "ssh")