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 207cf3d5d4 ('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.
This commit is contained in:
Thomas Haller 2021-05-27 09:23:01 +02:00
parent ce1dd0c0de
commit 840dd8cbcd
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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;
}