ryantimwilson / rpms / systemd

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