Blame SOURCES/0234-sd-bus-always-go-through-sd_bus_unref-to-free-messag.patch

a3e2b5
From 51c839c733ff53061807d92326830b5fe8499041 Mon Sep 17 00:00:00 2001
a3e2b5
From: Lennart Poettering <lennart@poettering.net>
a3e2b5
Date: Thu, 17 Jan 2019 21:07:42 +0100
a3e2b5
Subject: [PATCH] sd-bus: always go through sd_bus_unref() to free messages
a3e2b5
a3e2b5
Don't try to be smart, don't bypass the ref counting logic if there's no
a3e2b5
real reason to.
a3e2b5
a3e2b5
This matters if we want to tweak the ref counting logic later.
a3e2b5
a3e2b5
(cherry picked from commit b41812d1e308de03c879cfca490105216d528c4b)
a3e2b5
Related: CVE-2020-1712
a3e2b5
---
a3e2b5
 src/libsystemd/sd-bus/bus-message.c | 12 +++++-------
a3e2b5
 1 file changed, 5 insertions(+), 7 deletions(-)
a3e2b5
a3e2b5
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
a3e2b5
index 2ea3c5bba9..ac19cc04bf 100644
a3e2b5
--- a/src/libsystemd/sd-bus/bus-message.c
a3e2b5
+++ b/src/libsystemd/sd-bus/bus-message.c
a3e2b5
@@ -138,8 +138,6 @@ static sd_bus_message* message_free(sd_bus_message *m) {
a3e2b5
         return mfree(m);
a3e2b5
 }
a3e2b5
 
a3e2b5
-DEFINE_TRIVIAL_CLEANUP_FUNC(sd_bus_message*, message_free);
a3e2b5
-
a3e2b5
 static void *message_extend_fields(sd_bus_message *m, size_t align, size_t sz, bool add_offset) {
a3e2b5
         void *op, *np;
a3e2b5
         size_t old_size, new_size, start;
a3e2b5
@@ -531,7 +529,7 @@ int bus_message_from_malloc(
a3e2b5
                 const char *label,
a3e2b5
                 sd_bus_message **ret) {
a3e2b5
 
a3e2b5
-        _cleanup_(message_freep) sd_bus_message *m = NULL;
a3e2b5
+        _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
a3e2b5
         size_t sz;
a3e2b5
         int r;
a3e2b5
 
a3e2b5
@@ -651,7 +649,7 @@ _public_ int sd_bus_message_new_method_call(
a3e2b5
                 const char *interface,
a3e2b5
                 const char *member) {
a3e2b5
 
a3e2b5
-        _cleanup_(message_freep) sd_bus_message *t = NULL;
a3e2b5
+        _cleanup_(sd_bus_message_unrefp) sd_bus_message *t = NULL;
a3e2b5
         int r;
a3e2b5
 
a3e2b5
         assert_return(bus, -ENOTCONN);
a3e2b5
@@ -696,7 +694,7 @@ static int message_new_reply(
a3e2b5
                 uint8_t type,
a3e2b5
                 sd_bus_message **m) {
a3e2b5
 
a3e2b5
-        _cleanup_(message_freep) sd_bus_message *t = NULL;
a3e2b5
+        _cleanup_(sd_bus_message_unrefp) sd_bus_message *t = NULL;
a3e2b5
         uint64_t cookie;
a3e2b5
         int r;
a3e2b5
 
a3e2b5
@@ -747,7 +745,7 @@ _public_ int sd_bus_message_new_method_error(
a3e2b5
                 sd_bus_message **m,
a3e2b5
                 const sd_bus_error *e) {
a3e2b5
 
a3e2b5
-        _cleanup_(message_freep) sd_bus_message *t = NULL;
a3e2b5
+        _cleanup_(sd_bus_message_unrefp) sd_bus_message *t = NULL;
a3e2b5
         int r;
a3e2b5
 
a3e2b5
         assert_return(sd_bus_error_is_set(e), -EINVAL);
a3e2b5
@@ -850,7 +848,7 @@ int bus_message_new_synthetic_error(
a3e2b5
                 const sd_bus_error *e,
a3e2b5
                 sd_bus_message **m) {
a3e2b5
 
a3e2b5
-        _cleanup_(message_freep) sd_bus_message *t = NULL;
a3e2b5
+        _cleanup_(sd_bus_message_unrefp) sd_bus_message *t = NULL;
a3e2b5
         int r;
a3e2b5
 
a3e2b5
         assert(bus);