[telepathy-mission-control/master] fd.o #21544: mcd-account-compat: don't crash if properties are set to wrong types

Simon McVittie simon.mcvittie at collabora.co.uk
Tue May 5 08:20:29 PDT 2009


Also add a FIXME note: we should probably do more validation in both cases,
but I don't know what the semantics of these fields are meant to be.
---
 src/mcd-account-compat.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/mcd-account-compat.c b/src/mcd-account-compat.c
index 5581703..70c7ae5 100644
--- a/src/mcd-account-compat.c
+++ b/src/mcd-account-compat.c
@@ -60,6 +60,17 @@ set_profile (TpSvcDBusProperties *self, const gchar *name,
     const gchar *string, *unique_name;
     GKeyFile *keyfile;
 
+    if (!G_VALUE_HOLDS_STRING (value))
+    {
+        g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
+                     "Expected string for Profile, but got %s",
+                     G_VALUE_TYPE_NAME (value));
+        return FALSE;
+    }
+
+    /* FIXME: should we reject profile changes after account creation? */
+    /* FIXME: some sort of validation beyond just the type? */
+
     keyfile = _mcd_account_get_keyfile (account);
     unique_name = mcd_account_get_unique_name (account);
     string = g_value_get_string (value);
@@ -113,6 +124,16 @@ set_secondary_vcard_fields (TpSvcDBusProperties *self, const gchar *name,
     const gchar *unique_name, **fields, **field;
     GKeyFile *keyfile;
 
+    /* FIXME: some sort of validation beyond just the type? */
+
+    if (!G_VALUE_HOLDS (value, G_TYPE_STRV))
+    {
+        g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
+                     "Expected string-array for SecondaryVCardFields, but "
+                     "got %s", G_VALUE_TYPE_NAME (value));
+        return FALSE;
+    }
+
     keyfile = _mcd_account_get_keyfile (account);
     unique_name = mcd_account_get_unique_name (account);
     fields = g_value_get_boxed (value);
-- 
1.5.6.5




More information about the telepathy-commits mailing list