From 230eb628219a4822eebb5dc776df0fa79839d33a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 15 Dec 2017 12:11:53 +0100 Subject: [PATCH] libnm: verify value for connection.mdns Also, keep the internal variable of type int. The only way to set the field is via the GObject property setter. At that point, don't yet cast the integer type to enum. (cherry picked from commit eec907b35a1eb85f66cf9b9e031291354d7a0bc2) --- libnm-core/nm-setting-connection.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libnm-core/nm-setting-connection.c b/libnm-core/nm-setting-connection.c index 96fca5e9ee..bc99065e71 100644 --- a/libnm-core/nm-setting-connection.c +++ b/libnm-core/nm-setting-connection.c @@ -81,7 +81,7 @@ typedef struct { NMMetered metered; NMSettingConnectionLldp lldp; gint auth_retries; - NMSettingConnectionMdns mdns; + int mdns; } NMSettingConnectionPrivate; enum { @@ -1076,6 +1076,17 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } + if ( priv->mdns < NM_SETTING_CONNECTION_MDNS_UNKNOWN + || priv->mdns > NM_SETTING_CONNECTION_MDNS_RESOLVE) { + g_set_error (error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("mdns value %d is not valid"), priv->mdns); + g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, + NM_SETTING_CONNECTION_MDNS); + return FALSE; + } + /* *** errors above here should be always fatal, below NORMALIZABLE_ERROR *** */ if (!priv->uuid) {