From 88c2ccfb4c20cd1b4e34b31991f446b2f052478a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 1 Jun 2017 14:48:54 +0200 Subject: [PATCH] libnm: avoid assertion with invalid connections in _nm_connection_find_base_type_setting() Functions should behave gracefully with connections that don't verify. Especially, as _normalize_connection_type() calls _nm_connection_find_base_type_setting() precisely with an unknown connection.type. --- libnm-core/nm-connection.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libnm-core/nm-connection.c b/libnm-core/nm-connection.c index 4dd77a8b4d..e2f51dfb96 100644 --- a/libnm-core/nm-connection.c +++ b/libnm-core/nm-connection.c @@ -598,11 +598,14 @@ _nm_connection_find_base_type_setting (NMConnection *connection) continue; } else if (s_iter_prio == setting_prio) { NMSettingConnection *s_con = nm_connection_get_setting_connection (connection); + const char *type; - if (!s_con) - return NULL; - return nm_connection_get_setting_by_name (connection, - nm_setting_connection_get_connection_type (s_con)); + if (s_con) { + type = nm_setting_connection_get_connection_type (s_con); + if (type) + return nm_connection_get_setting_by_name (connection, type); + } + return NULL; } } setting = s_iter;