rpms/telepathy-salut/OLPC-2 salut-handle-check.patch, NONE, 1.1 telepathy-salut.spec, 1.26, 1.27

Dafydd Harries (daf) fedora-extras-commits at redhat.com
Tue Nov 20 16:31:17 UTC 2007


Author: daf

Update of /cvs/pkgs/rpms/telepathy-salut/OLPC-2
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22516

Modified Files:
	telepathy-salut.spec 
Added Files:
	salut-handle-check.patch 
Log Message:
* Mon Nov 19 2007 Dafydd Harries <dafydd.harries at collabora.co.uk> - 0.1.9-0.10.olpc2
- dev.laptop.org #5015: Fix crash due to handles not being validated.


salut-handle-check.patch:

--- NEW FILE salut-handle-check.patch ---
diff -rN -u old-telepathy-salut-cassidy-to-review/src/salut-connection.c new-telepathy-salut-cassidy-to-review/src/salut-connection.c
--- old-telepathy-salut-cassidy-to-review/src/salut-connection.c	2007-11-19 17:39:44.000000000 +0100
+++ new-telepathy-salut-cassidy-to-review/src/salut-connection.c	2007-11-19 17:39:45.000000000 +0100
@@ -1342,6 +1342,45 @@
       contact->olpc_color, contact->jid, contact->olpc_ip4, contact->olpc_ip6);
 }
 
+static gboolean
+check_handle (TpHandleRepoIface *handle_repo,
+              TpHandle handle,
+              DBusGMethodInvocation *context)
+{
+  GError *error = NULL;
+
+  if (!tp_handle_is_valid (handle_repo, handle, &error))
+    {
+      dbus_g_method_return_error (context, error);
+      g_error_free (error);
+      return FALSE;
+    }
+
+  return TRUE;
+}
+
+static gboolean
+check_contact (TpBaseConnection *base,
+               TpHandle contact,
+               DBusGMethodInvocation *context)
+{
+  TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
+      base, TP_HANDLE_TYPE_CONTACT);
+
+  return check_handle (contact_repo, contact, context);
+}
+
+static gboolean
+check_room (TpBaseConnection *base,
+            TpHandle contact,
+            DBusGMethodInvocation *context)
+{
+  TpHandleRepoIface *room_repo = tp_base_connection_get_handles (
+      base, TP_HANDLE_TYPE_ROOM);
+
+  return check_handle (room_repo, contact, context);
+}
+
 static void
 salut_connection_olpc_get_properties (SalutSvcOLPCBuddyInfo *iface,
                                       TpHandle handle,
@@ -1354,6 +1393,9 @@
 
   TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context);
 
+  if (!check_contact (base, handle, context))
+    return;
+
   if (handle == base->self_handle)
     {
       properties = get_properties_hash (priv->self->olpc_key,
@@ -1571,6 +1613,9 @@
 
   DEBUG ("called for %u", handle);
 
+  if (!check_contact (base, handle, context))
+    return;
+
   if (handle == base->self_handle)
     {
       DEBUG ("Returning my own cur.act.: %s -> %u",
@@ -1613,8 +1658,6 @@
   SalutConnection *self = SALUT_CONNECTION (iface);
   SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE (self);
   TpBaseConnection *base = (TpBaseConnection *) self;
-  TpHandleRepoIface *room_repo = tp_base_connection_get_handles (base,
-      TP_HANDLE_TYPE_ROOM);
   GError *error = NULL;
 
   TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context);
@@ -1634,12 +1677,8 @@
     }
   else
     {
-      if (!tp_handle_is_valid (room_repo, room_handle, &error))
-        {
-          dbus_g_method_return_error (context, error);
-          g_error_free (error);
-          return;
-        }
+      if (!check_room (base, room_handle, context))
+        return;
     }
 
   if (!salut_self_set_olpc_current_activity (priv->self, activity_id,
@@ -1667,6 +1706,9 @@
 
   DEBUG ("called for %u", handle);
 
+  if (!check_contact (base, handle, context))
+    return;
+
   if (handle == base->self_handle)
     {
       arr = g_ptr_array_new ();
@@ -2041,8 +2083,6 @@
   SalutConnection *self = SALUT_CONNECTION (iface);
   SalutConnectionPrivate *priv = SALUT_CONNECTION_GET_PRIVATE (self);
   TpBaseConnection *base = (TpBaseConnection *) self;
-  TpHandleRepoIface *room_repo = tp_base_connection_get_handles (base,
-      TP_HANDLE_TYPE_ROOM);
   GError *error = NULL;
   const gchar *known_properties[] = { "color", "name", "type", "private",
       "tags", NULL };
@@ -2051,8 +2091,8 @@
 
   TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context);
 
-  if (!tp_handle_is_valid(room_repo, handle, &error))
-    goto error;
+  if (!check_room (base, handle, context))
+    return;
 
   if (g_hash_table_find (properties, find_unknown_properties, known_properties)
       != NULL)



Index: telepathy-salut.spec
===================================================================
RCS file: /cvs/pkgs/rpms/telepathy-salut/OLPC-2/telepathy-salut.spec,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- telepathy-salut.spec	15 Nov 2007 22:21:37 -0000	1.26
+++ telepathy-salut.spec	20 Nov 2007 16:30:43 -0000	1.27
@@ -1,6 +1,6 @@
 Name:           telepathy-salut
 Version:        0.1.9
-Release:        0.9%{?dist}
+Release:        0.10%{?dist}
 Summary:        Link-local XMPP telepathy connection manager
 
 Group:          Applications/Communications
@@ -8,6 +8,7 @@
 URL:            http://telepathy.freedesktop.org/wiki/FrontPage
 Source0:        http://telepathy.freedesktop.org/releases/%{name}/%{name}-%{version}.tar.gz
 Patch0:         salut-olpc-no-dbus-uid-check.patch
+Patch1:         salut-handle-check.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires:  dbus-devel >= 1.1.0
@@ -58,6 +59,9 @@
 %{_mandir}/man8/%{name}.8.gz
 
 %changelog
+* Mon Nov 19 2007 Dafydd Harries <dafydd.harries at collabora.co.uk> - 0.1.9-0.10.olpc2
+- dev.laptop.org #5015: Fix crash due to handles not being validated.
+
 * Thu Nov 15 2007 Robert McQueen <robert.mcqueen at collabora.co.uk> - 0.1.9-0.9.olpc2
 - dev.laptop.org #4947: Add OLPC-specific patch to disable checking of the
   UID connecting to D-Bus tubes.




More information about the fedora-extras-commits mailing list