Blame SOURCES/0031-login-avoid-leak-of-name-returned-by-uid_to_name.patch

a3e2b5
From 8fdca31b41a6470ceda8e0a84f90a1e5ca28aa5c Mon Sep 17 00:00:00 2001
a3e2b5
From: David Tardon <dtardon@redhat.com>
a3e2b5
Date: Tue, 9 Oct 2018 17:26:19 +0200
a3e2b5
Subject: [PATCH] login: avoid leak of name returned by uid_to_name()
a3e2b5
a3e2b5
(cherry picked from commit e99742ef3e9d847da04e71fec0eb426063b25068)
a3e2b5
a3e2b5
Resolves: #1602706
a3e2b5
---
a3e2b5
 src/login/logind-dbus.c | 4 +++-
a3e2b5
 src/login/logind-utmp.c | 6 +++---
a3e2b5
 2 files changed, 6 insertions(+), 4 deletions(-)
a3e2b5
a3e2b5
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
a3e2b5
index 13298cc855..dca7f4a30f 100644
a3e2b5
--- a/src/login/logind-dbus.c
a3e2b5
+++ b/src/login/logind-dbus.c
a3e2b5
@@ -2155,6 +2155,7 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
a3e2b5
 
a3e2b5
         if (cancelled && m->enable_wall_messages) {
a3e2b5
                 _cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
a3e2b5
+                _cleanup_free_ char *username = NULL;
a3e2b5
                 const char *tty = NULL;
a3e2b5
                 uid_t uid = 0;
a3e2b5
                 int r;
a3e2b5
@@ -2165,8 +2166,9 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
a3e2b5
                         (void) sd_bus_creds_get_tty(creds, &tty);
a3e2b5
                 }
a3e2b5
 
a3e2b5
+                username = uid_to_name(uid);
a3e2b5
                 utmp_wall("The system shutdown has been cancelled",
a3e2b5
-                          uid_to_name(uid), tty, logind_wall_tty_filter, m);
a3e2b5
+                          username, tty, logind_wall_tty_filter, m);
a3e2b5
         }
a3e2b5
 
a3e2b5
         return sd_bus_reply_method_return(message, "b", cancelled);
a3e2b5
diff --git a/src/login/logind-utmp.c b/src/login/logind-utmp.c
a3e2b5
index 71ebdfcfb1..8bdd4ab6bf 100644
a3e2b5
--- a/src/login/logind-utmp.c
a3e2b5
+++ b/src/login/logind-utmp.c
a3e2b5
@@ -61,7 +61,7 @@ bool logind_wall_tty_filter(const char *tty, void *userdata) {
a3e2b5
 
a3e2b5
 static int warn_wall(Manager *m, usec_t n) {
a3e2b5
         char date[FORMAT_TIMESTAMP_MAX] = {};
a3e2b5
-        _cleanup_free_ char *l = NULL;
a3e2b5
+        _cleanup_free_ char *l = NULL, *username = NULL;
a3e2b5
         usec_t left;
a3e2b5
         int r;
a3e2b5
 
a3e2b5
@@ -83,8 +83,8 @@ static int warn_wall(Manager *m, usec_t n) {
a3e2b5
                 return 0;
a3e2b5
         }
a3e2b5
 
a3e2b5
-        utmp_wall(l, uid_to_name(m->scheduled_shutdown_uid),
a3e2b5
-                  m->scheduled_shutdown_tty, logind_wall_tty_filter, m);
a3e2b5
+        username = uid_to_name(m->scheduled_shutdown_uid);
a3e2b5
+        utmp_wall(l, username, m->scheduled_shutdown_tty, logind_wall_tty_filter, m);
a3e2b5
 
a3e2b5
         return 1;
a3e2b5
 }