mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 07:40:08 +01:00
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:
parent
ce1dd0c0de
commit
840dd8cbcd
1 changed files with 4 additions and 6 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue