From e6efe8b0660d18bf784deb0db0efbdb85cc7bb75 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Fri, 13 Dec 2024 08:22:40 +0100 Subject: [PATCH] core/utils: assert that completion results in a valid connection Completion of a connection must always result in a valid connection and the call to normalize() is always expected to succeed here. Croak if it doesn't because the rest basically relies on the connection being normalized. If it's not valid, and can't be normalized, it's a bug. --- src/core/NetworkManagerUtils.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/NetworkManagerUtils.c b/src/core/NetworkManagerUtils.c index d4180b0bc2..72ef47ab48 100644 --- a/src/core/NetworkManagerUtils.c +++ b/src/core/NetworkManagerUtils.c @@ -267,6 +267,7 @@ _nm_utils_complete_generic_with_params(NMPlatform *platform, va_list ap; const char *p_val; const char *p_key; + gboolean valid; g_assert(fallback_id_prefix); g_return_if_fail(ifname_prefix == NULL || ifname == NULL); @@ -315,7 +316,8 @@ _nm_utils_complete_generic_with_params(NMPlatform *platform, g_hash_table_insert(parameters, (char *) p_key, (char *) p_val); } va_end(ap); - nm_connection_normalize(connection, parameters, NULL, NULL); + valid = nm_connection_normalize(connection, parameters, NULL, NULL); + nm_assert(valid); } /*****************************************************************************/