From 127ac25ef8ddd08a78a4fa8b17df35c528b7a48c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 16 Oct 2018 15:05:01 +0200 Subject: cli: fix setting "serial.parity" enum MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The meta data type descriptor must set .get_gtype only for GObject properties which are of type int or uint. That is, when the enum type cannot be automatically detected. However, NM_SETTING_SERIAL_PARITY is a g_param_spec_enum() of type NM_TYPE_SETTING_SERIAL_PARITY, so setting the get_gtype() hook is wrong and leads to a crash $ /bin/nmcli connection add type gsm autoconnect no con-name t ifname '*' apn xyz serial.parity 5 (process:11086): libnmc-CRITICAL **: 15:04:35.180: file clients/common/nm-meta-setting-desc.c: line 1283 (_set_fcn_gobject_enum): should not be reached Segmentation fault (core dumped) That is because the enum property setter does: »···if ( has_gtype »··· && NM_IN_SET (gtype_prop, »··· G_TYPE_INT, »··· G_TYPE_UINT) »··· && G_TYPE_IS_CLASSED (gtype) »··· && (gtype_class = g_type_class_ref (gtype)) »··· && ( (is_flags = G_IS_FLAGS_CLASS (gtype_class)) »··· || G_IS_ENUM_CLASS (gtype_class))) { »···»···/* valid */ meaning, it only allows "has_gtype" if the native "gtype_prop" is G_TYPE_INT or G_TYPE_UINT. Fixes: 9a68123827a8c4fe1eeaaf003d365429441d97e9 --- clients/common/nm-meta-setting-desc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c index bd58e31370..9048e927a6 100644 --- a/clients/common/nm-meta-setting-desc.c +++ b/clients/common/nm-meta-setting-desc.c @@ -7152,7 +7152,6 @@ static const NMMetaPropertyInfo *const property_infos_SERIAL[] = { .property_type = &_pt_gobject_enum, .property_typ_data = DEFINE_PROPERTY_TYP_DATA ( PROPERTY_TYP_DATA_SUBTYPE (gobject_enum, - .get_gtype = nm_setting_serial_parity_get_type, .value_infos = ENUM_VALUE_INFOS ( { .value = NM_SETTING_SERIAL_PARITY_EVEN, -- cgit v1.2.1