[gnome-terminal/gnome-3-8] client: Validate UUID string (cherry picked from commit f7bb10accc1580a931142050eea279bc18ce8ec8)
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal/gnome-3-8] client: Validate UUID string (cherry picked from commit f7bb10accc1580a931142050eea279bc18ce8ec8)
- Date: Tue, 7 May 2013 18:50:00 +0000 (UTC)
commit 86001c26a8b019d51fc92bc69d9363a034eadc95
Author: Christian Persch <chpe gnome org>
Date: Tue May 7 20:47:04 2013 +0200
client: Validate UUID string
(cherry picked from commit f7bb10accc1580a931142050eea279bc18ce8ec8)
src/terminal-profiles-list.c | 15 ++++++++++++++-
src/terminal-settings-list.c | 18 +++++++++---------
src/terminal-settings-list.h | 2 ++
3 files changed, 25 insertions(+), 10 deletions(-)
---
diff --git a/src/terminal-profiles-list.c b/src/terminal-profiles-list.c
index 284cfd5..d68545c 100644
--- a/src/terminal-profiles-list.c
+++ b/src/terminal-profiles-list.c
@@ -50,6 +50,18 @@ strv_contains (char **strv,
return n;
}
+static gboolean
+valid_uuid (const char *str,
+ GError **error)
+{
+ if (terminal_settings_list_valid_uuid (str))
+ return TRUE;
+
+ g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
+ "\"%s\" is not a valid UUID", str);
+ return FALSE;
+}
+
/**
* terminal_profiles_list_new:
*
@@ -119,7 +131,8 @@ terminal_profiles_list_dup_uuid (TerminalSettingsList *list,
if (rv == NULL)
goto err;
return rv;
- }
+ } else if (!valid_uuid (uuid, error))
+ return NULL;
if (terminal_settings_list_has_child (list, uuid))
return g_strdup (uuid);
diff --git a/src/terminal-settings-list.c b/src/terminal-settings-list.c
index 84af9f0..7c7667c 100644
--- a/src/terminal-settings-list.c
+++ b/src/terminal-settings-list.c
@@ -165,8 +165,8 @@ strv_dupv_remove (char **strv,
return nstrv;
}
-static gboolean
-is_valid_uuid (const char *str)
+gboolean
+terminal_settings_list_valid_uuid (const char *str)
{
uuid_t u;
@@ -199,7 +199,7 @@ validate_list (TerminalSettingsList *list,
return allow_empty;
for (i = 0; entries[i]; i++) {
- if (!is_valid_uuid (entries[i]))
+ if (!terminal_settings_list_valid_uuid (entries[i]))
return FALSE;
}
@@ -701,7 +701,7 @@ terminal_settings_list_has_child (TerminalSettingsList *list,
const char *uuid)
{
g_return_val_if_fail (TERMINAL_IS_SETTINGS_LIST (list), FALSE);
- g_return_val_if_fail (is_valid_uuid (uuid), FALSE);
+ g_return_val_if_fail (terminal_settings_list_valid_uuid (uuid), FALSE);
return strv_find (list->uuids, uuid) != -1;
}
@@ -721,7 +721,7 @@ terminal_settings_list_ref_child (TerminalSettingsList *list,
const char *uuid)
{
g_return_val_if_fail (TERMINAL_IS_SETTINGS_LIST (list), NULL);
- g_return_val_if_fail (is_valid_uuid (uuid), NULL);
+ g_return_val_if_fail (terminal_settings_list_valid_uuid (uuid), NULL);
return terminal_settings_list_ref_child_internal (list, uuid);
}
@@ -806,7 +806,7 @@ terminal_settings_list_clone_child (TerminalSettingsList *list,
const char *uuid)
{
g_return_val_if_fail (TERMINAL_IS_SETTINGS_LIST (list), NULL);
- g_return_val_if_fail (is_valid_uuid (uuid), NULL);
+ g_return_val_if_fail (terminal_settings_list_valid_uuid (uuid), NULL);
return terminal_settings_list_add_child_internal (list, uuid);
}
@@ -823,7 +823,7 @@ terminal_settings_list_remove_child (TerminalSettingsList *list,
const char *uuid)
{
g_return_if_fail (TERMINAL_IS_SETTINGS_LIST (list));
- g_return_if_fail (is_valid_uuid (uuid));
+ g_return_if_fail (terminal_settings_list_valid_uuid (uuid));
terminal_settings_list_remove_child_internal (list, uuid);
}
@@ -853,7 +853,7 @@ terminal_settings_list_dup_uuid_from_child (TerminalSettingsList *list,
p++;
g_return_val_if_fail (strlen (p) == 37, NULL);
p[36] = '\0';
- g_return_val_if_fail (is_valid_uuid (p), NULL);
+ g_return_val_if_fail (terminal_settings_list_valid_uuid (p), NULL);
p = g_strdup (p);
g_free (path);
@@ -872,7 +872,7 @@ terminal_settings_list_set_default_child (TerminalSettingsList *list,
const char *uuid)
{
g_return_if_fail (TERMINAL_IS_SETTINGS_LIST (list));
- g_return_if_fail (is_valid_uuid (uuid));
+ g_return_if_fail (terminal_settings_list_valid_uuid (uuid));
if (!terminal_settings_list_has_child (list, uuid))
return;
diff --git a/src/terminal-settings-list.h b/src/terminal-settings-list.h
index ff00c99..ed37611 100644
--- a/src/terminal-settings-list.h
+++ b/src/terminal-settings-list.h
@@ -69,6 +69,8 @@ char *terminal_settings_list_dup_default_child (TerminalSettingsList *list);
void terminal_settings_list_set_default_child (TerminalSettingsList *list,
const char *uuid);
+gboolean terminal_settings_list_valid_uuid (const char *str);
+
G_END_DECLS
#endif /* TERMINAL_SETTINGS_LIST_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]