~ubuntu-branches/ubuntu/lucid/dbus-glib/lucid-updates

« back to all changes in this revision

Viewing changes to debian/patches/01-20884-proxy-manager-replace-name-owner.patch

  • Committer: Bazaar Package Importer
  • Author(s): Simon McVittie, Michael Biebl, Simon McVittie
  • Date: 2009-04-27 12:00:42 UTC
  • mfrom: (2.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090427120042-drhdldcquusmlhlg
Tags: 0.80-4
[ Michael Biebl ]
* debian/control
  - Changes section of libdbus-glib-1-2-dbg.
  - Bump Standards-Version to 3.8.1. No further changes.

[ Simon McVittie ]
* Apply my patch from upstream git to fix invalid memory accesses in
  DBusGProxyManager after the first of a process's names is removed
  (freedesktop.org #20884)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
commit f36381131b6f410333a9a823a4fc131ac799394f
 
2
Author: Simon McVittie <simon.mcvittie@collabora.co.uk>
 
3
Date:   2009-03-26 18:00:16 +0000
 
4
 
 
5
    fd.o#20884: dbus_g_proxy_manager_replace_name_owner: don't leave freed memory in the hash table if the name was the owner's first
 
6
    
 
7
    Here's a situation where this code would fail:
 
8
    
 
9
    * an owner :1.42 owns a name com.Example and a name org.Example
 
10
    * the owner_names hash table contains { :1.42 => c }, where
 
11
      c is a GSList link with data = "com.Example", next = o and
 
12
      o is a GSList link with data = "org.Example", next = NULL
 
13
    * the name owner for com.Example changes so :1.42 no longer owns the
 
14
      name
 
15
    * initially, names == c
 
16
    * g_slist_delete_link unlinks and frees c, and sets names = o
 
17
    * but c is still in the hash table, so next time we look in the hash
 
18
      table, we crash
 
19
    
 
20
    The fix is to replace c with o in the owner_names hash table.
 
21
 
 
22
diff --git a/dbus/dbus-gproxy.c b/dbus/dbus-gproxy.c
 
23
index b379c20..572b7fb 100644
 
24
--- a/dbus/dbus-gproxy.c
 
25
+++ b/dbus/dbus-gproxy.c
 
26
@@ -753,9 +753,16 @@ dbus_g_proxy_manager_replace_name_owner (DBusGProxyManager  *manager,
 
27
          
 
28
              names = g_slist_delete_link (names, link);
 
29
 
 
30
-             if (names == NULL)
 
31
-               g_hash_table_remove (manager->owner_names, prev_owner);
 
32
-           }
 
33
+              if (names == NULL)
 
34
+                {
 
35
+                  g_hash_table_remove (manager->owner_names, prev_owner);
 
36
+                }
 
37
+              else
 
38
+                {
 
39
+                  g_hash_table_insert (manager->owner_names,
 
40
+                                       g_strdup (prev_owner), names);
 
41
+                }
 
42
+            }
 
43
         }
 
44
 
 
45
       if (new_owner[0] == '\0')