tdecacqu / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone
60ed166
From d3d5865931637112cd80fe5c95bcbf894b283a45 Mon Sep 17 00:00:00 2001
60ed166
From: David Herrmann <dh.herrmann@gmail.com>
60ed166
Date: Sat, 5 Sep 2015 12:56:04 +0200
60ed166
Subject: [PATCH 10/12] login: fix NULL-deref on wall_message
60ed166
60ed166
We treat an empty wall-message equal to a NULL wall-message since:
60ed166
60ed166
        commit 5744f59a3ee883ef3a78214bd5236157acdc35ba
60ed166
        Author: Lennart Poettering <lennart@poettering.net>
60ed166
        Date:   Fri Sep 4 10:34:47 2015 +0200
60ed166
60ed166
            logind: treat an empty wall message like a NULL one
60ed166
60ed166
Fix the shutdown scheduler to not deref a NULL pointer, but properly
60ed166
check for an empty wall-message.
60ed166
60ed166
Fixes: #1120
60ed166
(cherry picked from commit 3d1c455f9a898e7427b642800644ae7142dc7557)
60ed166
60ed166
Resolves: #1279156
60ed166
---
60ed166
 src/login/logind-dbus.c | 10 ++++++----
60ed166
 1 file changed, 6 insertions(+), 4 deletions(-)
60ed166
60ed166
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
60ed166
index 1c1011c..c180ce1 100644
60ed166
--- a/src/login/logind-dbus.c
60ed166
+++ b/src/login/logind-dbus.c
60ed166
@@ -1795,9 +1795,11 @@ static int update_schedule_file(Manager *m) {
60ed166
         if (r < 0)
60ed166
                 return log_error_errno(r, "Failed to create shutdown subdirectory: %m");
60ed166
 
60ed166
-        t = cescape(m->wall_message);
60ed166
-        if (!t)
60ed166
-                return log_oom();
60ed166
+        if (!isempty(m->wall_message)) {
60ed166
+                t = cescape(m->wall_message);
60ed166
+                if (!t)
60ed166
+                        return log_oom();
60ed166
+        }
60ed166
 
60ed166
         r = fopen_temporary("/run/systemd/shutdown/scheduled", &f, &temp_path);
60ed166
         if (r < 0)
60ed166
@@ -1813,7 +1815,7 @@ static int update_schedule_file(Manager *m) {
60ed166
                 m->enable_wall_messages,
60ed166
                 m->scheduled_shutdown_type);
60ed166
 
60ed166
-        if (!isempty(m->wall_message))
60ed166
+        if (t)
60ed166
                 fprintf(f, "WALL_MESSAGE=%s\n", t);
60ed166
 
60ed166
         (void) fflush_and_check(f);
60ed166
-- 
60ed166
2.5.0
60ed166