teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0204-timedate-fix-memory-leak-in-timedated.patch

923a60
From 266eacb3e5a46caba3a56485a9ba54ad8027ff61 Mon Sep 17 00:00:00 2001
923a60
From: =?UTF-8?q?Cristian=20Rodr=C3=ADguez?= <crrodriguez@opensuse.org>
923a60
Date: Fri, 15 May 2015 13:26:18 -0300
923a60
Subject: [PATCH] timedate: fix memory leak in timedated
923a60
923a60
$ /usr/lib/systemd/systemd-timedated (wait until auto-exit)
923a60
923a60
=================================================================
923a60
==396==ERROR: LeakSanitizer: detected memory leaks
923a60
923a60
Direct leak of 928 byte(s) in 1 object(s) allocated from:
923a60
    #0 0x7f782f788db1 in __interceptor_calloc (/usr/lib64/libasan.so.2+0x96db1)
923a60
    #1 0x562a83ae60cf in bus_message_from_header src/libsystemd/sd-bus/bus-message.c:480
923a60
    #2 0x562a83ae6f5a in bus_message_from_malloc src/libsystemd/sd-bus/bus-message.c:576
923a60
    #3 0x562a83ad3cad in bus_socket_make_message src/libsystemd/sd-bus/bus-socket.c:915
923a60
    #4 0x562a83ad4cfc in bus_socket_read_message src/libsystemd/sd-bus/bus-socket.c:1051
923a60
    #5 0x562a83ab733f in bus_read_message src/libsystemd/sd-bus/sd-bus.c:1647
923a60
    #6 0x562a83ab98ea in sd_bus_call src/libsystemd/sd-bus/sd-bus.c:2038
923a60
    #7 0x562a83b1f46d in sd_bus_call_method src/libsystemd/sd-bus/bus-convenience.c:94
923a60
    #8 0x562a83aab3e1 in context_read_ntp src/timedate/timedated.c:192
923a60
    #9 0x562a83aae1af in main src/timedate/timedated.c:730
923a60
    #10 0x7f782eb238c4 in __libc_start_main (/lib64/libc.so.6+0x208c4)
923a60
923a60
Indirect leak of 77 byte(s) in 1 object(s) allocated from:
923a60
    #0 0x7f782f788f6a in realloc (/usr/lib64/libasan.so.2+0x96f6a)
923a60
    #1 0x562a83ad418a in bus_socket_read_message src/libsystemd/sd-bus/bus-socket.c:963
923a60
    #2 0x562a83ab733f in bus_read_message src/libsystemd/sd-bus/sd-bus.c:1647
923a60
    #3 0x562a83ab98ea in sd_bus_call src/libsystemd/sd-bus/sd-bus.c:2038
923a60
    #4 0x562a83b1f46d in sd_bus_call_method src/libsystemd/sd-bus/bus-convenience.c:94
923a60
    #5 0x562a83aab3e1 in context_read_ntp src/timedate/timedated.c:192
923a60
    #6 0x562a83aae1af in main src/timedate/timedated.c:730
923a60
    #7 0x7f782eb238c4 in __libc_start_main (/lib64/libc.so.6+0x208c4)
923a60
923a60
Indirect leak of 2 byte(s) in 1 object(s) allocated from:
923a60
    #0 0x7f782f75493f in strdup (/usr/lib64/libasan.so.2+0x6293f)
923a60
    #1 0x562a83b0229b in bus_message_parse_fields src/libsystemd/sd-bus/bus-message.c:5382
923a60
    #2 0x562a83ae7290 in bus_message_from_malloc src/libsystemd/sd-bus/bus-message.c:601
923a60
    #3 0x562a83ad3cad in bus_socket_make_message src/libsystemd/sd-bus/bus-socket.c:915
923a60
    #4 0x562a83ad4cfc in bus_socket_read_message src/libsystemd/sd-bus/bus-socket.c:1051
923a60
    #5 0x562a83ab733f in bus_read_message src/libsystemd/sd-bus/sd-bus.c:1647
923a60
    #6 0x562a83ab98ea in sd_bus_call src/libsystemd/sd-bus/sd-bus.c:2038
923a60
    #7 0x562a83b1f46d in sd_bus_call_method src/libsystemd/sd-bus/bus-convenience.c:94
923a60
    #8 0x562a83aab3e1 in context_read_ntp src/timedate/timedated.c:192
923a60
    #9 0x562a83aae1af in main src/timedate/timedated.c:730
923a60
    #10 0x7f782eb238c4 in __libc_start_main (/lib64/libc.so.6+0x208c4)
923a60
923a60
SUMMARY: AddressSanitizer: 1007 byte(s) leaked in 3 allocation(s).
923a60
923a60
This is due to missing  _cleanup_bus_message_unref_ in context_read_ntp()
923a60
923a60
(cherry picked from commit 6b71bab08dc6c92156263daba0e969313eed1323)
923a60
923a60
Cherry-picked from: 6b71bab
923a60
Resolves: #1222517
923a60
---
923a60
 src/timedate/timedated.c | 2 +-
923a60
 1 file changed, 1 insertion(+), 1 deletion(-)
923a60
923a60
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
923a60
index f875149364..09d0dbabcd 100644
923a60
--- a/src/timedate/timedated.c
923a60
+++ b/src/timedate/timedated.c
923a60
@@ -245,7 +245,7 @@ static int context_read_ntp(Context *c, sd_bus *bus) {
923a60
         l = get_ntp_services();
923a60
         STRV_FOREACH(i, l) {
923a60
                 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
923a60
-                sd_bus_message *reply = NULL;
923a60
+                _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
923a60
                 const char *s;
923a60
 
923a60
                 r = sd_bus_call_method(