Package: telepathy-haze
Version: 0.2.0-1
Severity: important
Tags: patch

Released versions of telepathy-haze crash if the 'server' parameter for
protocols which have one is blank or contains spaces, due to an
assertion failure in libpurple.  Some versions of Empathy apparently set
blank server parameters; I had thought that it has been fixed, but this
crash was reported to me again a couple of days ago.  The attached patch
makes haze validate that parameter, and reject it if it contains spaces
or is blank.

(This is <https://bugs.freedesktop.org/show_bug.cgi?id=14445>.)

-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (900, 'testing'), (800, 'unstable'), (700, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.25-2-686 (SMP w/1 CPU core)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
commit 53835d7664c07173a444996d9fe47a6a2306de88
Author: Will Thompson <[EMAIL PROTECTED]>
Date:   Sun Feb 17 12:40:14 2008 +0000

    Reject server parameters which are blank or contain spaces
    
    
    20080217124014-9f02e-844ab52f25f64993d1603863c356f07b2b4e2a1f.gz
---
 src/connection-manager.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/src/connection-manager.c b/src/connection-manager.c
index 3072b50..c240db2 100644
--- a/src/connection-manager.c
+++ b/src/connection-manager.c
@@ -104,6 +104,32 @@ _haze_cm_set_param (const TpCMParamSpec *paramspec,
     g_hash_table_insert (params, prpl_param_name, value_copy);
 }
 
+static gboolean
+_param_filter_no_blanks (const TpCMParamSpec *paramspec,
+                         GValue *value,
+                         GError **error)
+{
+    const gchar *str = g_value_get_string (value);
+
+    if (*str == '\0')
+    {
+        g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
+            "Account parameter '%s' must not be empty",
+            paramspec->name);
+        return FALSE;
+    }
+
+    if (strstr (str, " ") != NULL)
+    {
+        g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
+            "Account parameter '%s' may not contain spaces",
+            paramspec->name);
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
 /* Populates a TpCMParamSpec from a PurpleAccountOption, possibly renaming the
  * parameter as specified in parameter_map.  paramspec is assumed to be zeroed out.
  * Returns TRUE on success, and FALSE if paramspec could not be populated (and
@@ -179,6 +205,9 @@ _translate_protocol_option (PurpleAccountOption *option,
             return FALSE;
     }
 
+    if (g_str_equal (paramspec->name, "server"))
+        paramspec->filter = _param_filter_no_blanks;
+
     return TRUE;
 }
 

Reply via email to