mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 05:10:09 +01:00
libnm-util: validate connection uuid
This commit is contained in:
parent
756bc70402
commit
eee3c4ceb2
1 changed files with 18 additions and 1 deletions
|
|
@ -24,6 +24,7 @@
|
|||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "nm-setting-connection.h"
|
||||
|
||||
/**
|
||||
|
|
@ -218,6 +219,22 @@ find_setting_by_name (gconstpointer a, gconstpointer b)
|
|||
return strcmp (nm_setting_get_name (setting), str);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
validate_uuid (const char *uuid)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!uuid || !strlen (uuid))
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < strlen (uuid); i++) {
|
||||
if (!isxdigit (uuid[i]) && (uuid[i] != '-'))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||
{
|
||||
|
|
@ -243,7 +260,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
NM_SETTING_CONNECTION_ERROR_MISSING_PROPERTY,
|
||||
NM_SETTING_CONNECTION_UUID);
|
||||
return FALSE;
|
||||
} else if (!strlen (priv->uuid)) {
|
||||
} else if (!validate_uuid (priv->uuid)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_CONNECTION_ERROR,
|
||||
NM_SETTING_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue