From 840dd8cbcd1d5a9ed0c42e25ff565d86bfea5aaf Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 27 May 2021 09:23:01 +0200 Subject: [PATCH] settings: in assertion to check valid UUID use nm_uuid_is_valid_full() In the past, the UUID was only loosely validate and would accept forms that are not valid. This was fixed by commit 207cf3d5d4c9 ('libnm: normalize "connection.uuid"'). Now the UUID is always strictly valid and lower case. Thus, don't use the fuzzy nm_utils_is_uuid() from libnm but the exact check nm_uuid_is_valid_full(). Note that this is only used for assertions in the header file. We thus don't want to drag in "libnm-glib-aux/nm-uuid.h". Instead, we forward declare the function. lgtm.com warns about declarations are block scope, so fix that too by moving the declaration at file scope. --- src/core/settings/nm-settings-storage.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/core/settings/nm-settings-storage.h b/src/core/settings/nm-settings-storage.h index 37bf12d2a7..d873a485bd 100644 --- a/src/core/settings/nm-settings-storage.h +++ b/src/core/settings/nm-settings-storage.h @@ -60,25 +60,23 @@ nm_settings_storage_get_plugin(const NMSettingsStorage *self) return self->_plugin; } +gboolean nm_uuid_is_valid_full(const char *str); + static inline const char * nm_settings_storage_get_uuid(const NMSettingsStorage *self) { - gboolean nm_utils_is_uuid(const char *str); - g_return_val_if_fail(NM_IS_SETTINGS_STORAGE(self), NULL); - nm_assert(nm_utils_is_uuid(self->_uuid)); + nm_assert(nm_uuid_is_valid_full(self->_uuid)); return self->_uuid; } static inline const char * nm_settings_storage_get_uuid_opt(const NMSettingsStorage *self) { - gboolean nm_utils_is_uuid(const char *str); - g_return_val_if_fail(NM_IS_SETTINGS_STORAGE(self), NULL); - nm_assert(!self->_uuid || nm_utils_is_uuid(self->_uuid)); + nm_assert(!self->_uuid || nm_uuid_is_valid_full(self->_uuid)); return self->_uuid; }