diff options
author | Dan Williams <dcbw@redhat.com> | 2009-05-03 01:09:07 -0400 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2009-05-03 01:09:34 -0400 |
commit | eee3c4ceb2f2a27b9baf23c76e5c8cfc50e48377 (patch) | |
tree | ec625e0973e56d277daca904426d9ff66a8bd7c6 /libnm-util | |
parent | 756bc704029050af94ef678bb4c0bdc02da14034 (diff) |
libnm-util: validate connection uuid
Diffstat (limited to 'libnm-util')
-rw-r--r-- | libnm-util/nm-setting-connection.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/libnm-util/nm-setting-connection.c b/libnm-util/nm-setting-connection.c index 86cb8fb2d8..113262f52d 100644 --- a/libnm-util/nm-setting-connection.c +++ b/libnm-util/nm-setting-connection.c @@ -24,6 +24,7 @@ */ #include <string.h> +#include <ctype.h> #include "nm-setting-connection.h" /** @@ -219,6 +220,22 @@ find_setting_by_name (gconstpointer a, gconstpointer b) } 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) { NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE (setting); @@ -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, |