From 1543f8a1a18d16c9bcb6f0a14ada8c4e68df8994 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 30 Jun 2020 19:31:08 +0200 Subject: [PATCH] libnm: don't fail assertion for _bond_get_option_normalized() with invalid bond mode _bond_get_option_normalized() gets called with code paths that don't assume a valid options hash. That means, the bond mode might be invalid and we should fail an assertion. --- libnm-core/nm-setting-bond.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libnm-core/nm-setting-bond.c b/libnm-core/nm-setting-bond.c index 162024c70..2ef7075f9 100644 --- a/libnm-core/nm-setting-bond.c +++ b/libnm-core/nm-setting-bond.c @@ -262,7 +262,11 @@ _bond_get_option_normalized (NMSettingBond* self, mode_str = _bond_get_option_or_default (self, NM_SETTING_BOND_OPTION_MODE); mode = _nm_setting_bond_mode_from_string (mode_str); - g_return_val_if_fail (mode != NM_BOND_MODE_UNKNOWN, NULL); + if (mode == NM_BOND_MODE_UNKNOWN) { + /* the mode is unknown, consequently, there is no normalized/default + * value either. */ + return NULL; + } if (!_nm_setting_bond_option_supported (option, mode)) return NULL;