]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
home: fix heap-use-after-free 21769/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 14 Dec 2021 06:38:12 +0000 (15:38 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 14 Dec 2021 11:00:56 +0000 (20:00 +0900)
`bus_home_emit_remove()` may be called from manager_free() -> home_free().
In that case, manager->bus is already unref()ed.

Fixes #21767.

src/home/homed-home-bus.c

index 9e9f537d6c883499faddfe457988992a3dfbe1c6..61d4690780944d565703bd96095064b48545ff48 100644 (file)
@@ -940,6 +940,12 @@ int bus_home_emit_remove(Home *h) {
         if (!h->announced)
                 return 0;
 
+        if (!h->manager)
+                return 0;
+
+        if (!h->manager->bus)
+                return 0;
+
         r = bus_home_path(h, &path);
         if (r < 0)
                 return r;