valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

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

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