diff options
Diffstat (limited to 'libnm-util')
| -rw-r--r-- | libnm-util/Makefile.am | 3 | ||||
| -rw-r--r-- | libnm-util/Makefile.in | 37 | ||||
| -rw-r--r-- | libnm-util/NetworkManager.h | 10 | ||||
| -rw-r--r-- | libnm-util/nm-connection.c | 2 | ||||
| -rw-r--r-- | libnm-util/nm-setting-adsl.c | 11 | ||||
| -rw-r--r-- | libnm-util/nm-setting-cdma.c | 11 | ||||
| -rw-r--r-- | libnm-util/nm-setting-connection.c | 18 | ||||
| -rw-r--r-- | libnm-util/nm-setting-dcb.c | 14 | ||||
| -rw-r--r-- | libnm-util/nm-setting-gsm.c | 11 | ||||
| -rw-r--r-- | libnm-util/nm-setting-ip4-config.c | 10 | ||||
| -rw-r--r-- | libnm-util/nm-setting-ip6-config.c | 44 | ||||
| -rw-r--r-- | libnm-util/nm-setting-team-port.c | 12 | ||||
| -rw-r--r-- | libnm-util/nm-setting-wired.c | 33 | ||||
| -rw-r--r-- | libnm-util/nm-setting-wireless-security.c | 52 | ||||
| -rw-r--r-- | libnm-util/nm-utils.c | 2 | ||||
| -rw-r--r-- | libnm-util/nm-version.h.in | 2 | ||||
| -rw-r--r-- | libnm-util/tests/Makefile.am | 1 | ||||
| -rw-r--r-- | libnm-util/tests/Makefile.in | 32 | ||||
| -rw-r--r-- | libnm-util/tests/test-crypto.c | 5 | ||||
| -rw-r--r-- | libnm-util/tests/test-general.c | 30 | ||||
| -rw-r--r-- | libnm-util/tests/test-secrets.c | 22 | ||||
| -rw-r--r-- | libnm-util/tests/test-setting-8021x.c | 3 | ||||
| -rw-r--r-- | libnm-util/tests/test-setting-dcb.c | 11 |
23 files changed, 210 insertions, 166 deletions
diff --git a/libnm-util/Makefile.am b/libnm-util/Makefile.am index 3fdc79e5..fbf8c0b3 100644 --- a/libnm-util/Makefile.am +++ b/libnm-util/Makefile.am @@ -155,7 +155,6 @@ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libnm-util.pc DISTCLEANFILES = libnm-util.pc -CLEANFILES = nm-version.h EXTRA_DIST = libnm-util.pc.in libnm-util.ver nm-version.h.in @@ -183,7 +182,7 @@ gir_DATA = $(INTROSPECTION_GIRS) typelibdir = $(libdir)/girepository-1.0 typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) -CLEANFILES += $(gir_DATA) $(typelib_DATA) +CLEANFILES = $(gir_DATA) $(typelib_DATA) endif diff --git a/libnm-util/Makefile.in b/libnm-util/Makefile.in index 5dea1b42..87271131 100644 --- a/libnm-util/Makefile.in +++ b/libnm-util/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.13.4 from Makefile.am. +# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -17,7 +17,17 @@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -91,12 +101,7 @@ host_triplet = @host@ @WITH_NSS_TRUE@am__append_9 = crypto_nss.c @WITH_NSS_TRUE@am__append_10 = $(NSS_LIBS) @HAVE_INTROSPECTION_TRUE@am__append_11 = NetworkManager-1.0.gir -@HAVE_INTROSPECTION_TRUE@am__append_12 = $(gir_DATA) $(typelib_DATA) subdir = libnm-util -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(srcdir)/libnm-util.pc.in $(srcdir)/nm-version.h.in \ - $(top_srcdir)/build-aux/depcomp $(libnm_util_include_HEADERS) \ - COPYING ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ $(top_srcdir)/m4/compiler_warnings.m4 \ @@ -113,6 +118,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(libnm_util_include_HEADERS) \ + $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = libnm-util.pc nm-version.h @@ -285,6 +292,9 @@ am__define_uniq_tagged_files = \ ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) +am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/libnm-util.pc.in \ + $(srcdir)/nm-version.h.in $(top_srcdir)/build-aux/depcomp \ + COPYING DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ @@ -336,7 +346,6 @@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ -DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ @@ -371,6 +380,7 @@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ GTKDOC_MKPDF = @GTKDOC_MKPDF@ @@ -682,7 +692,6 @@ libtest_crypto_la_LIBADD = $(GLIB_LIBS) $(am__append_8) \ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libnm-util.pc DISTCLEANFILES = libnm-util.pc -CLEANFILES = nm-version.h $(am__append_12) EXTRA_DIST = libnm-util.pc.in libnm-util.ver nm-version.h.in INTROSPECTION_GIRS = $(am__append_11) INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) @@ -699,6 +708,7 @@ INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) @HAVE_INTROSPECTION_TRUE@gir_DATA = $(INTROSPECTION_GIRS) @HAVE_INTROSPECTION_TRUE@typelibdir = $(libdir)/girepository-1.0 @HAVE_INTROSPECTION_TRUE@typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) +@HAVE_INTROSPECTION_TRUE@CLEANFILES = $(gir_DATA) $(typelib_DATA) all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-recursive @@ -716,7 +726,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libnm-util/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu libnm-util/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -838,14 +847,14 @@ distclean-compile: @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -1264,6 +1273,8 @@ uninstall-am: uninstall-girDATA uninstall-libLTLIBRARIES \ uninstall-nodist_libnm_util_includeHEADERS \ uninstall-pkgconfigDATA uninstall-typelibDATA +.PRECIOUS: Makefile + include $(GLIB_MAKEFILE) -include $(INTROSPECTION_MAKEFILE) diff --git a/libnm-util/NetworkManager.h b/libnm-util/NetworkManager.h index 08b4e6cf..5a98b8e4 100644 --- a/libnm-util/NetworkManager.h +++ b/libnm-util/NetworkManager.h @@ -204,6 +204,9 @@ typedef enum { * @NM_WIFI_DEVICE_CAP_RSN: device supports WPA2/RSN authentication * @NM_WIFI_DEVICE_CAP_AP: device supports Access Point mode * @NM_WIFI_DEVICE_CAP_ADHOC: device supports Ad-Hoc mode + * @NM_WIFI_DEVICE_CAP_FREQ_VALID: device reports frequency capabilities + * @NM_WIFI_DEVICE_CAP_FREQ_2GHZ: device supports 2.4GHz frequencies + * @NM_WIFI_DEVICE_CAP_FREQ_5GHZ: device supports 5GHz frequencies * * 802.11 specific device encryption and authentication capabilities. * @@ -218,7 +221,10 @@ typedef enum { NM_WIFI_DEVICE_CAP_WPA = 0x00000010, NM_WIFI_DEVICE_CAP_RSN = 0x00000020, NM_WIFI_DEVICE_CAP_AP = 0x00000040, - NM_WIFI_DEVICE_CAP_ADHOC = 0x00000080 + NM_WIFI_DEVICE_CAP_ADHOC = 0x00000080, + NM_WIFI_DEVICE_CAP_FREQ_VALID = 0x00000100, + NM_WIFI_DEVICE_CAP_FREQ_2GHZ = 0x00000200, + NM_WIFI_DEVICE_CAP_FREQ_5GHZ = 0x00000400, } NMDeviceWifiCapabilities; @@ -465,6 +471,7 @@ typedef enum { * @NM_DEVICE_STATE_REASON_MODEM_FAILED: Modem failed or no longer available * @NM_DEVICE_STATE_REASON_MODEM_AVAILABLE: Modem now ready and available * @NM_DEVICE_STATE_REASON_SIM_PIN_INCORRECT: SIM PIN was incorrect + * @NM_DEVICE_STATE_REASON_NEW_ACTIVATION: New connection activation was enqueued * * Device state change reason codes * @@ -531,6 +538,7 @@ typedef enum { NM_DEVICE_STATE_REASON_MODEM_FAILED = 57, NM_DEVICE_STATE_REASON_MODEM_AVAILABLE = 58, NM_DEVICE_STATE_REASON_SIM_PIN_INCORRECT = 59, + NM_DEVICE_STATE_REASON_NEW_ACTIVATION = 60, NM_DEVICE_STATE_REASON_LAST = 0xFFFF } NMDeviceStateReason; diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c index a1350f54..3a929b04 100644 --- a/libnm-util/nm-connection.c +++ b/libnm-util/nm-connection.c @@ -1241,7 +1241,7 @@ nm_connection_to_hash (NMConnection *connection, NMSettingHashFlags flags) g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); ret = g_hash_table_new_full (g_str_hash, g_str_equal, - g_free, (GDestroyNotify) g_hash_table_destroy); + g_free, (GDestroyNotify) g_hash_table_unref); priv = NM_CONNECTION_GET_PRIVATE (connection); diff --git a/libnm-util/nm-setting-adsl.c b/libnm-util/nm-setting-adsl.c index 601ebc2b..5355011c 100644 --- a/libnm-util/nm-setting-adsl.c +++ b/libnm-util/nm-setting-adsl.c @@ -219,15 +219,6 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) return FALSE; } - if (priv->password && !strlen (priv->password)) { - g_set_error_literal (error, - NM_SETTING_ADSL_ERROR, - NM_SETTING_ADSL_ERROR_INVALID_PROPERTY, - _("property is empty")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_ADSL_SETTING_NAME, NM_SETTING_ADSL_PASSWORD); - return FALSE; - } - if ( !priv->protocol || ( strcmp (priv->protocol, NM_SETTING_ADSL_PROTOCOL_PPPOA) && strcmp (priv->protocol, NM_SETTING_ADSL_PROTOCOL_PPPOE) @@ -262,7 +253,7 @@ need_secrets (NMSetting *setting) NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE (setting); GPtrArray *secrets = NULL; - if (priv->password) + if (priv->password && *priv->password) return NULL; if (!(priv->password_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED)) { diff --git a/libnm-util/nm-setting-cdma.c b/libnm-util/nm-setting-cdma.c index 44a893c7..53f886ec 100644 --- a/libnm-util/nm-setting-cdma.c +++ b/libnm-util/nm-setting-cdma.c @@ -181,15 +181,6 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) return FALSE; } - if (priv->password && !strlen (priv->password)) { - g_set_error_literal (error, - NM_SETTING_CDMA_ERROR, - NM_SETTING_CDMA_ERROR_INVALID_PROPERTY, - _("property is empty")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_CDMA_SETTING_NAME, NM_SETTING_CDMA_PASSWORD); - return FALSE; - } - return TRUE; } @@ -199,7 +190,7 @@ need_secrets (NMSetting *setting) NMSettingCdmaPrivate *priv = NM_SETTING_CDMA_GET_PRIVATE (setting); GPtrArray *secrets = NULL; - if (priv->password) + if (priv->password && *priv->password) return NULL; if (priv->username) { diff --git a/libnm-util/nm-setting-connection.c b/libnm-util/nm-setting-connection.c index 162ae7cb..bda89d63 100644 --- a/libnm-util/nm-setting-connection.c +++ b/libnm-util/nm-setting-connection.c @@ -882,19 +882,21 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) if (is_slave) { if (!priv->master) { - g_set_error_literal (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, - _("Slave connections need a valid '" NM_SETTING_CONNECTION_MASTER "' property")); + g_set_error (error, + NM_SETTING_CONNECTION_ERROR, + NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, + _("Slave connections need a valid '%s' property"), + NM_SETTING_CONNECTION_MASTER); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_MASTER); return NM_SETTING_VERIFY_ERROR; } } else { if (priv->master) { - g_set_error_literal (error, - NM_SETTING_CONNECTION_ERROR, - NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, - _("Cannot set '" NM_SETTING_CONNECTION_MASTER "' without '" NM_SETTING_CONNECTION_SLAVE_TYPE "'")); + g_set_error (error, + NM_SETTING_CONNECTION_ERROR, + NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY, + _("Cannot set '%s' without '%s'"), + NM_SETTING_CONNECTION_MASTER, NM_SETTING_CONNECTION_SLAVE_TYPE); g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_SLAVE_TYPE); return NM_SETTING_VERIFY_ERROR; } diff --git a/libnm-util/nm-setting-dcb.c b/libnm-util/nm-setting-dcb.c index 2376581e..89ee3878 100644 --- a/libnm-util/nm-setting-dcb.c +++ b/libnm-util/nm-setting-dcb.c @@ -78,7 +78,7 @@ NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_DCB) typedef struct { NMSettingDcbFlags app_fcoe_flags; gint app_fcoe_priority; - const char * app_fcoe_mode; + char * app_fcoe_mode; NMSettingDcbFlags app_iscsi_flags; gint app_iscsi_priority; @@ -833,6 +833,7 @@ set_property (GObject *object, guint prop_id, priv->app_fcoe_priority = g_value_get_int (value); break; case PROP_APP_FCOE_MODE: + g_free (priv->app_fcoe_mode); priv->app_fcoe_mode = g_value_dup_string (value); break; case PROP_APP_ISCSI_FLAGS: @@ -945,6 +946,16 @@ get_property (GObject *object, guint prop_id, } static void +finalize (GObject *object) +{ + NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE (object); + + g_free (priv->app_fcoe_mode); + + G_OBJECT_CLASS (nm_setting_dcb_parent_class)->finalize (object); +} + +static void nm_setting_dcb_class_init (NMSettingDcbClass *setting_class) { GObjectClass *object_class = G_OBJECT_CLASS (setting_class); @@ -955,6 +966,7 @@ nm_setting_dcb_class_init (NMSettingDcbClass *setting_class) /* virtual methods */ object_class->set_property = set_property; object_class->get_property = get_property; + object_class->finalize = finalize; parent_class->verify = verify; /* Properties */ diff --git a/libnm-util/nm-setting-gsm.c b/libnm-util/nm-setting-gsm.c index a17d18b7..e422c92e 100644 --- a/libnm-util/nm-setting-gsm.c +++ b/libnm-util/nm-setting-gsm.c @@ -342,15 +342,6 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) return FALSE; } - if (priv->password && !strlen (priv->password)) { - g_set_error_literal (error, - NM_SETTING_GSM_ERROR, - NM_SETTING_GSM_ERROR_INVALID_PROPERTY, - _("property is empty")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_USERNAME); - return FALSE; - } - if (priv->network_id) { guint32 nid_len = strlen (priv->network_id); guint32 i; @@ -388,7 +379,7 @@ need_secrets (NMSetting *setting) NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (setting); GPtrArray *secrets = NULL; - if (priv->password) + if (priv->password && *priv->password) return NULL; if (priv->username) { diff --git a/libnm-util/nm-setting-ip4-config.c b/libnm-util/nm-setting-ip4-config.c index 532231ab..4db43cbc 100644 --- a/libnm-util/nm-setting-ip4-config.c +++ b/libnm-util/nm-setting-ip4-config.c @@ -959,16 +959,6 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) NMIP4Route *route = (NMIP4Route *) iter->data; guint32 prefix = nm_ip4_route_get_prefix (route); - if (!nm_ip4_route_get_dest (route)) { - g_set_error (error, - NM_SETTING_IP4_CONFIG_ERROR, - NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY, - _("%d. route is invalid"), - i+1); - g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_ROUTES); - return FALSE; - } - if (!prefix || prefix > 32) { g_set_error (error, NM_SETTING_IP4_CONFIG_ERROR, diff --git a/libnm-util/nm-setting-ip6-config.c b/libnm-util/nm-setting-ip6-config.c index 654f0496..4e69a072 100644 --- a/libnm-util/nm-setting-ip6-config.c +++ b/libnm-util/nm-setting-ip6-config.c @@ -825,6 +825,8 @@ static gboolean verify (NMSetting *setting, GSList *all_settings, GError **error) { NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting); + GSList *iter; + int i; if (!priv->method) { g_set_error_literal (error, @@ -899,6 +901,48 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) return FALSE; } + /* Validate addresses */ + for (iter = priv->addresses, i = 0; iter; iter = g_slist_next (iter), i++) { + NMIP6Address *addr = (NMIP6Address *) iter->data; + guint32 prefix = nm_ip6_address_get_prefix (addr); + + if (IN6_IS_ADDR_UNSPECIFIED (nm_ip6_address_get_address (addr))) { + g_set_error (error, + NM_SETTING_IP6_CONFIG_ERROR, + NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY, + _("%d. IPv6 address is invalid"), + i+1); + g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_ADDRESSES); + return FALSE; + } + + if (!prefix || prefix > 128) { + g_set_error (error, + NM_SETTING_IP6_CONFIG_ERROR, + NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY, + _("%d. IPv6 address has invalid prefix"), + i+1); + g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_ADDRESSES); + return FALSE; + } + } + + /* Validate routes */ + for (iter = priv->routes, i = 0; iter; iter = g_slist_next (iter), i++) { + NMIP6Route *route = (NMIP6Route *) iter->data; + guint32 prefix = nm_ip6_route_get_prefix (route); + + if (!prefix || prefix > 128) { + g_set_error (error, + NM_SETTING_IP6_CONFIG_ERROR, + NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY, + _("%d. route has invalid prefix"), + i+1); + g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_ROUTES); + return FALSE; + } + } + return TRUE; } diff --git a/libnm-util/nm-setting-team-port.c b/libnm-util/nm-setting-team-port.c index 6bc71c98..9992f58a 100644 --- a/libnm-util/nm-setting-team-port.c +++ b/libnm-util/nm-setting-team-port.c @@ -130,6 +130,7 @@ set_property (GObject *object, guint prop_id, switch (prop_id) { case PROP_CONFIG: + g_free (priv->config); priv->config = g_value_dup_string (value); break; default: @@ -155,6 +156,16 @@ get_property (GObject *object, guint prop_id, } static void +finalize (GObject *object) +{ + NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE (object); + + g_free (priv->config); + + G_OBJECT_CLASS (nm_setting_team_port_parent_class)->finalize (object); +} + +static void nm_setting_team_port_class_init (NMSettingTeamPortClass *setting_class) { GObjectClass *object_class = G_OBJECT_CLASS (setting_class); @@ -165,6 +176,7 @@ nm_setting_team_port_class_init (NMSettingTeamPortClass *setting_class) /* virtual methods */ object_class->set_property = set_property; object_class->get_property = get_property; + object_class->finalize = finalize; parent_class->verify = verify; /* Properties */ diff --git a/libnm-util/nm-setting-wired.c b/libnm-util/nm-setting-wired.c index 8d927921..aba5fb98 100644 --- a/libnm-util/nm-setting-wired.c +++ b/libnm-util/nm-setting-wired.c @@ -474,27 +474,24 @@ nm_setting_wired_get_s390_option (NMSettingWired *setting, const char **out_key, const char **out_value) { - NMSettingWiredPrivate *priv; - guint32 num_keys; - GList *keys; - const char *_key = NULL, *_value = NULL; + const char *_key, *_value; + GHashTableIter iter; + guint i = 0; g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE); - priv = NM_SETTING_WIRED_GET_PRIVATE (setting); - - num_keys = nm_setting_wired_get_num_s390_options (setting); - g_return_val_if_fail (idx < num_keys, FALSE); - - keys = g_hash_table_get_keys (priv->s390_options); - _key = g_list_nth_data (keys, idx); - _value = g_hash_table_lookup (priv->s390_options, _key); - - if (out_key) - *out_key = _key; - if (out_value) - *out_value = _value; - return TRUE; + g_hash_table_iter_init (&iter, NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options); + while (g_hash_table_iter_next (&iter, (gpointer) &_key, (gpointer) &_value)) { + if (i == idx) { + if (out_key) + *out_key = _key; + if (out_value) + *out_value = _value; + return TRUE; + } + i++; + } + g_return_val_if_reached (FALSE); } /** diff --git a/libnm-util/nm-setting-wireless-security.c b/libnm-util/nm-setting-wireless-security.c index 5e3456ce..574ff3bd 100644 --- a/libnm-util/nm-setting-wireless-security.c +++ b/libnm-util/nm-setting-wireless-security.c @@ -852,7 +852,7 @@ need_secrets (NMSetting *setting) if ( priv->auth_alg && !strcmp (priv->auth_alg, "leap") && !strcmp (priv->key_mgmt, "ieee8021x")) { - if (!priv->leap_password || !strlen (priv->leap_password)) { + if (!priv->leap_password || !*priv->leap_password) { g_ptr_array_add (secrets, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD); return secrets; } @@ -923,14 +923,6 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME); return FALSE; } - if (priv->leap_password && !strlen (priv->leap_password)) { - g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - _("property is empty")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD); - return FALSE; - } } else { if ( (strcmp (priv->key_mgmt, "ieee8021x") == 0) || (strcmp (priv->key_mgmt, "wpa-eap") == 0)) { @@ -975,39 +967,6 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) return FALSE; } - if (priv->wep_key0 && !nm_utils_wep_key_valid (priv->wep_key0, priv->wep_key_type)) { - g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - _("property is invalid")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0); - return FALSE; - } - if (priv->wep_key1 && !nm_utils_wep_key_valid (priv->wep_key1, priv->wep_key_type)) { - g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - _("property is invalid")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_KEY1); - return FALSE; - } - if (priv->wep_key2 && !nm_utils_wep_key_valid (priv->wep_key2, priv->wep_key_type)) { - g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - _("property is invalid")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_KEY2); - return FALSE; - } - if (priv->wep_key3 && !nm_utils_wep_key_valid (priv->wep_key3, priv->wep_key_type)) { - g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - _("property is invalid")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3); - return FALSE; - } - if (priv->auth_alg && !_nm_utils_string_in_list (priv->auth_alg, valid_auth_algs)) { g_set_error_literal (error, NM_SETTING_WIRELESS_SECURITY_ERROR, @@ -1017,15 +976,6 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) return FALSE; } - if (priv->psk && !nm_utils_wpa_psk_valid (priv->psk)) { - g_set_error_literal (error, - NM_SETTING_WIRELESS_SECURITY_ERROR, - NM_SETTING_WIRELESS_SECURITY_ERROR_INVALID_PROPERTY, - _("property is invalid")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NM_SETTING_WIRELESS_SECURITY_PSK); - return FALSE; - } - if (priv->proto && !_nm_utils_string_slist_validate (priv->proto, valid_protos)) { g_set_error_literal (error, NM_SETTING_WIRELESS_SECURITY_ERROR, diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c index 203803f2..022fa70f 100644 --- a/libnm-util/nm-utils.c +++ b/libnm-util/nm-utils.c @@ -1756,7 +1756,7 @@ nm_utils_file_is_pkcs12 (const char *filename) * for additional checks. This check is performed after the check for * @file_test_flags. You cannot omit both @file_test_flags and @predicate. * @user_data: (closure): (allow-none): user data for @predicate function. - * @error: on failure, a "not found" error using @error_domain and @error_code + * @error: (allow-none): on failure, set a "not found" error %G_IO_ERROR %G_IO_ERROR_NOT_FOUND. * * Searches for a @progname file in a list of search @paths. * diff --git a/libnm-util/nm-version.h.in b/libnm-util/nm-version.h.in index 0a33ac29..bbbf993a 100644 --- a/libnm-util/nm-version.h.in +++ b/libnm-util/nm-version.h.in @@ -68,7 +68,7 @@ #define NM_VERSION_0_9_10 (NM_ENCODE_VERSION (0, 9, 10)) #define NM_VERSION_1_0 (NM_ENCODE_VERSION (1, 0, 0)) -#define NM_VERSION_CUR_STABLE NM_VERSION_0_9_10 +#define NM_VERSION_CUR_STABLE NM_VERSION_1_0 #define NM_VERSION_NEXT_STABLE NM_VERSION_1_0 #if !defined (NM_VERSION_MIN_REQUIRED) || (NM_VERSION_MIN_REQUIRED == 0) diff --git a/libnm-util/tests/Makefile.am b/libnm-util/tests/Makefile.am index 690bdbf6..16a7f8f3 100644 --- a/libnm-util/tests/Makefile.am +++ b/libnm-util/tests/Makefile.am @@ -10,6 +10,7 @@ AM_CPPFLAGS = \ -DBUILD_DIR=\"$(abs_builddir)\" \ -DTEST_CERT_DIR=\"$(top_srcdir)/libnm-core/tests/certs/\" +@VALGRIND_RULES@ TESTS = \ test-settings-defaults \ test-crypto \ diff --git a/libnm-util/tests/Makefile.in b/libnm-util/tests/Makefile.in index 9ef02e8c..5ef0d87b 100644 --- a/libnm-util/tests/Makefile.in +++ b/libnm-util/tests/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.13.4 from Makefile.am. +# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2013 Free Software Foundation, Inc. +# Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -15,7 +15,17 @@ @SET_MAKE@ VPATH = @srcdir@ -am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ @@ -86,8 +96,6 @@ host_triplet = @host@ @ENABLE_TESTS_TRUE@noinst_PROGRAMS = $(am__EXEEXT_1) \ @ENABLE_TESTS_TRUE@ test-libnm-linking$(EXEEXT) subdir = libnm-util/tests -DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ - $(top_srcdir)/build-aux/depcomp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ $(top_srcdir)/m4/compiler_warnings.m4 \ @@ -104,6 +112,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_readline.m4 \ $(top_srcdir)/m4/vapigen.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = @@ -254,6 +263,8 @@ am__tty_colors = { \ std='[m'; \ fi; \ } +am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(top_srcdir)/build-aux/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALL_LINGUAS = @ALL_LINGUAS@ @@ -280,7 +291,6 @@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ -DATADIRNAME = @DATADIRNAME@ DBUS_CFLAGS = @DBUS_CFLAGS@ DBUS_GLIB_100_CFLAGS = @DBUS_GLIB_100_CFLAGS@ DBUS_GLIB_100_LIBS = @DBUS_GLIB_100_LIBS@ @@ -315,6 +325,7 @@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_CHECK_PATH = @GTKDOC_CHECK_PATH@ GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ GTKDOC_MKPDF = @GTKDOC_MKPDF@ @@ -599,7 +610,6 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libnm-util/tests/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu libnm-util/tests/Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ @@ -674,14 +684,14 @@ distclean-compile: @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -993,6 +1003,10 @@ uninstall-am: mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am +.PRECIOUS: Makefile + + +@ENABLE_TESTS_TRUE@@VALGRIND_RULES@ # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/libnm-util/tests/test-crypto.c b/libnm-util/tests/test-crypto.c index 4bf2b3be..8055facf 100644 --- a/libnm-util/tests/test-crypto.c +++ b/libnm-util/tests/test-crypto.c @@ -96,7 +96,7 @@ out: static void test_cert (gconstpointer test_data) { - char *path; + gs_free char *path = NULL; GByteArray *array; NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN; GError *error = NULL; @@ -153,6 +153,7 @@ test_load_private_key (const char *path, "unexpected failure determining private key file '%s' " "type with invalid password (expected %d, got %d)", path, NM_CRYPTO_KEY_TYPE_UNKNOWN, key_type); + g_clear_error (&error); return; } @@ -183,6 +184,7 @@ test_load_private_key (const char *path, g_byte_array_free (decrypted, TRUE); } + g_clear_error (&error); g_byte_array_free (array, TRUE); } @@ -207,6 +209,7 @@ test_load_pkcs12 (const char *path, "%d): %d %s", path, NM_CRYPTO_FILE_FORMAT_PKCS12, format, error->code, error->message); } + g_clear_error (&error); } static void diff --git a/libnm-util/tests/test-general.c b/libnm-util/tests/test-general.c index f748fcf5..d8f9dcc4 100644 --- a/libnm-util/tests/test-general.c +++ b/libnm-util/tests/test-general.c @@ -30,6 +30,7 @@ #include <sys/resource.h> #include <nm-utils.h> +#include "gsystem-local-alloc.h" #include "nm-setting-private.h" #include "nm-setting-connection.h" @@ -310,6 +311,13 @@ test_setting_vpn_modify_during_foreach (void) g_object_unref (s_vpn); } +static void +_g_value_array_free (void *ptr) +{ + if (ptr) + g_value_array_free ((GValueArray *) ptr); +} + #define OLD_DBUS_TYPE_G_IP6_ADDRESS (dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, G_TYPE_INVALID)) #define OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS (dbus_g_type_get_collection ("GPtrArray", OLD_DBUS_TYPE_G_IP6_ADDRESS)) @@ -338,7 +346,7 @@ test_setting_ip6_config_old_address_array (void) g_value_init (&written_value, OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS); - addresses = g_ptr_array_new (); + addresses = g_ptr_array_new_full (0, _g_value_array_free); array = g_value_array_new (3); /* IP address */ @@ -398,6 +406,7 @@ test_setting_ip6_config_old_address_array (void) ASSERT (memcmp (ba->data, &gw[0], sizeof (gw)) == 0, "ip6-old-addr", "unexpected failure comparing gateways"); + g_ptr_array_unref (addresses); g_value_unset (&written_value); g_value_unset (&read_value); g_object_unref (s_ip6); @@ -406,7 +415,7 @@ test_setting_ip6_config_old_address_array (void) static void test_setting_gsm_apn_spaces (void) { - NMSettingGsm *s_gsm; + gs_unref_object NMSettingGsm *s_gsm = NULL; const char *tmp; s_gsm = (NMSettingGsm *) nm_setting_gsm_new (); @@ -434,7 +443,7 @@ test_setting_gsm_apn_spaces (void) static void test_setting_gsm_apn_bad_chars (void) { - NMSettingGsm *s_gsm; + gs_unref_object NMSettingGsm *s_gsm = NULL; s_gsm = (NMSettingGsm *) nm_setting_gsm_new (); ASSERT (s_gsm != NULL, @@ -472,7 +481,7 @@ test_setting_gsm_apn_bad_chars (void) static void test_setting_gsm_apn_underscore (void) { - NMSettingGsm *s_gsm; + gs_unref_object NMSettingGsm *s_gsm = NULL; GError *error = NULL; gboolean success; @@ -491,7 +500,7 @@ test_setting_gsm_apn_underscore (void) static void test_setting_gsm_without_number (void) { - NMSettingGsm *s_gsm; + gs_unref_object NMSettingGsm *s_gsm = NULL; GError *error = NULL; gboolean success; @@ -1573,6 +1582,7 @@ test_connection_good_base_types (void) NM_SETTING_GSM_APN, "metered.billing.sucks", NULL); nm_connection_add_setting (connection, setting); + g_clear_object (&connection); /* CDMA connection */ connection = nm_connection_new (); @@ -1671,7 +1681,7 @@ test_connection_bad_base_types (void) static void test_setting_compare_id (void) { - NMSetting *old, *new; + gs_unref_object NMSetting *old = NULL, *new = NULL; gboolean success; old = nm_setting_connection_new (); @@ -1697,7 +1707,7 @@ test_setting_compare_secrets (NMSettingSecretFlags secret_flags, NMSettingCompareFlags comp_flags, gboolean remove_secret) { - NMSetting *old, *new; + gs_unref_object NMSetting *old = NULL, *new = NULL; gboolean success; /* Make sure that a connection with transient/unsaved secrets compares @@ -1729,7 +1739,7 @@ test_setting_compare_vpn_secrets (NMSettingSecretFlags secret_flags, NMSettingCompareFlags comp_flags, gboolean remove_secret) { - NMSetting *old, *new; + gs_unref_object NMSetting *old = NULL, *new = NULL; gboolean success; /* Make sure that a connection with transient/unsaved secrets compares @@ -1908,7 +1918,7 @@ test_setting_connection_changed_signal (void) NMConnection *connection; gboolean changed = FALSE; NMSettingConnection *s_con; - char *uuid; + gs_free char *uuid = NULL; connection = nm_connection_new (); g_signal_connect (connection, @@ -2318,7 +2328,7 @@ static void test_setting_old_uuid (void) { GError *error = NULL; - NMSetting *setting; + gs_unref_object NMSetting *setting = NULL; gboolean success; /* NetworkManager-0.9.4.0 generated 40-character UUIDs with no dashes, diff --git a/libnm-util/tests/test-secrets.c b/libnm-util/tests/test-secrets.c index fb0ad4c7..a22edb0f 100644 --- a/libnm-util/tests/test-secrets.c +++ b/libnm-util/tests/test-secrets.c @@ -176,6 +176,7 @@ test_need_tls_secrets_path (void) "need-tls-secrets-path-key-password", "expected to require private key password, but it wasn't"); + g_ptr_array_free (hints, TRUE); g_object_unref (connection); } @@ -219,6 +220,7 @@ test_need_tls_secrets_blob (void) "need-tls-secrets-blob-key-password", "expected to require private key password, but it wasn't"); + g_ptr_array_free (hints, TRUE); g_object_unref (connection); } @@ -345,6 +347,7 @@ test_need_tls_phase2_secrets_path (void) "need-tls-phase2-secrets-path-key-password", "expected to require private key password, but it wasn't"); + g_ptr_array_free (hints, TRUE); g_object_unref (connection); } @@ -389,6 +392,7 @@ test_need_tls_phase2_secrets_blob (void) "need-tls-phase2-secrets-blob-key-password", "expected to require private key password, but it wasn't"); + g_ptr_array_free (hints, TRUE); g_object_unref (connection); } @@ -507,6 +511,7 @@ test_update_secrets_wifi_single_setting (void) tmp = nm_setting_wireless_security_get_wep_key (s_wsec, 0); g_assert_cmpstr (tmp, ==, wepkey); + g_hash_table_unref (secrets); g_object_unref (connection); } @@ -547,6 +552,7 @@ test_update_secrets_wifi_full_hash (void) tmp = nm_setting_wireless_security_get_wep_key (s_wsec, 0); g_assert_cmpstr (tmp, ==, wepkey); + g_hash_table_unref (all); g_object_unref (connection); } @@ -577,6 +583,8 @@ test_update_secrets_wifi_bad_setting_name (void) g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND); g_assert (success == FALSE); + g_clear_error (&error); + g_hash_table_unref (secrets); g_object_unref (connection); } @@ -600,7 +608,7 @@ test_update_secrets_whole_connection (void) secrets = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL); wsec_hash = g_hash_table_lookup (secrets, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); g_assert (wsec_hash); - g_hash_table_insert (wsec_hash, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, string_to_gvalue (wepkey)); + g_hash_table_insert (wsec_hash, g_strdup (NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), string_to_gvalue (wepkey)); success = nm_connection_update_secrets (connection, NULL, secrets, &error); g_assert_no_error (error); @@ -610,6 +618,7 @@ test_update_secrets_whole_connection (void) g_assert (s_wsec); g_assert_cmpstr (nm_setting_wireless_security_get_wep_key (s_wsec, 0), ==, wepkey); + g_hash_table_unref (secrets); g_object_unref (connection); } @@ -629,6 +638,7 @@ test_update_secrets_whole_connection_empty_hash (void) g_assert_no_error (error); g_assert (success == TRUE); g_object_unref (connection); + g_hash_table_unref (secrets); } static void @@ -650,20 +660,23 @@ test_update_secrets_whole_connection_bad_setting (void) secrets = nm_connection_to_hash (connection, NM_SETTING_HASH_FLAG_ALL); wsec_hash = g_hash_table_lookup (secrets, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); g_assert (wsec_hash); - g_hash_table_insert (wsec_hash, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, string_to_gvalue (wepkey)); + g_hash_table_insert (wsec_hash, g_strdup (NM_SETTING_WIRELESS_SECURITY_WEP_KEY0), string_to_gvalue (wepkey)); /* Steal the wsec setting hash so it's not deallocated, and stuff it back * in with a different name so we ensure libnm-util is returning the right * error when it finds an entry in the connection hash that doesn't match * any setting in the connection. */ - g_hash_table_steal (secrets, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); - g_hash_table_insert (secrets, "asdfasdfasdfasdf", wsec_hash); + g_hash_table_ref (wsec_hash); + g_hash_table_remove (secrets, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME); + g_hash_table_insert (secrets, g_strdup ("asdfasdfasdfasdf"), wsec_hash); success = nm_connection_update_secrets (connection, NULL, secrets, &error); g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND); g_assert (success == FALSE); + g_clear_error (&error); + g_hash_table_destroy (secrets); g_object_unref (connection); } @@ -716,6 +729,7 @@ test_update_secrets_null_setting_name_with_setting_hash (void) g_assert_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_SETTING_NOT_FOUND); g_assert (!success); + g_clear_error (&error); g_hash_table_destroy (secrets); g_object_unref (connection); } diff --git a/libnm-util/tests/test-setting-8021x.c b/libnm-util/tests/test-setting-8021x.c index 4b37d92b..dfc07a80 100644 --- a/libnm-util/tests/test-setting-8021x.c +++ b/libnm-util/tests/test-setting-8021x.c @@ -188,6 +188,7 @@ test_phase2_private_key_import (const char *path, g_object_get (s_8021x, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, &tmp_key, NULL); ASSERT (tmp_key != NULL, "phase2-private-key-import", "missing private key value"); check_scheme_path (tmp_key, path); + g_byte_array_free (tmp_key, TRUE); } else g_assert_not_reached (); @@ -249,6 +250,7 @@ test_wrong_password_keeps_data (const char *path, const char *password) "wrong-password-keeps-data", "unexpected missing error"); ASSERT (format == NM_SETTING_802_1X_CK_FORMAT_UNKNOWN, "wrong-password-keeps-data", "unexpected success reading private key format"); + g_clear_error (&error); /* Make sure the password hasn't changed */ pw = nm_setting_802_1x_get_private_key_password (s_8021x); @@ -346,6 +348,7 @@ test_wrong_phase2_password_keeps_data (const char *path, const char *password) "wrong-phase2-password-keeps-data", "unexpected missing error"); ASSERT (format == NM_SETTING_802_1X_CK_FORMAT_UNKNOWN, "wrong-phase2-password-keeps-data", "unexpected success reading private key format"); + g_clear_error (&error); /* Make sure the password hasn't changed */ pw = nm_setting_802_1x_get_phase2_private_key_password (s_8021x); diff --git a/libnm-util/tests/test-setting-dcb.c b/libnm-util/tests/test-setting-dcb.c index 1c7d78b8..36192cd3 100644 --- a/libnm-util/tests/test-setting-dcb.c +++ b/libnm-util/tests/test-setting-dcb.c @@ -26,6 +26,7 @@ #include <nm-utils.h> #include <nm-glib-compat.h> #include "nm-setting-dcb.h" +#include "gsystem-local-alloc.h" #define DCB_FLAGS_ALL (NM_SETTING_DCB_FLAG_ENABLE | \ NM_SETTING_DCB_FLAG_ADVERTISE | \ @@ -34,7 +35,7 @@ static void test_dcb_flags_valid (void) { - NMSettingDcb *s_dcb; + gs_unref_object NMSettingDcb *s_dcb = NULL; GError *error = NULL; gboolean success; guint i; @@ -87,7 +88,7 @@ test_dcb_flags_valid (void) static void test_dcb_flags_invalid (void) { - NMSettingDcb *s_dcb; + gs_unref_object NMSettingDcb *s_dcb = NULL; GError *error = NULL; gboolean success; @@ -146,7 +147,7 @@ test_dcb_flags_invalid (void) static void test_dcb_app_priorities (void) { - NMSettingDcb *s_dcb; + gs_unref_object NMSettingDcb *s_dcb = NULL; GError *error = NULL; gboolean success; @@ -208,7 +209,7 @@ test_dcb_app_priorities (void) static void test_dcb_priorities_valid (void) { - NMSettingDcb *s_dcb; + gs_unref_object NMSettingDcb *s_dcb = NULL; GError *error = NULL; gboolean success; guint i; @@ -267,7 +268,7 @@ test_dcb_priorities_valid (void) static void test_dcb_bandwidth_sums (void) { - NMSettingDcb *s_dcb; + gs_unref_object NMSettingDcb *s_dcb = NULL; GError *error = NULL; gboolean success; |