summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2015-09-05 12:56:04 +0200
committerSven Eden <yamakuzure@gmx.net>2017-03-14 10:19:06 +0100
commitba5bb9837fda291f45cffa97fe8347e045a93694 (patch)
tree14b39c3efe762212fd2c25ac36b6eca5f6c96adc /src
parente53c43f27a5a71c302eeecd7f6c66b47226b543e (diff)
login: fix NULL-deref on wall_message
We treat an empty wall-message equal to a NULL wall-message since: commit 5744f59a3ee883ef3a78214bd5236157acdc35ba Author: Lennart Poettering <lennart@poettering.net> Date: Fri Sep 4 10:34:47 2015 +0200 logind: treat an empty wall message like a NULL one Fix the shutdown scheduler to not deref a NULL pointer, but properly check for an empty wall-message. Fixes: #1120
Diffstat (limited to 'src')
-rw-r--r--src/login/logind-dbus.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index cdb3007ac..def9f3927 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -1783,9 +1783,11 @@ static int update_schedule_file(Manager *m) {
if (r < 0)
return log_error_errno(r, "Failed to create shutdown subdirectory: %m");
- t = cescape(m->wall_message);
- if (!t)
- return log_oom();
+ if (!isempty(m->wall_message)) {
+ t = cescape(m->wall_message);
+ if (!t)
+ return log_oom();
+ }
r = fopen_temporary("/run/systemd/shutdown/scheduled", &f, &temp_path);
if (r < 0)
@@ -1801,7 +1803,7 @@ static int update_schedule_file(Manager *m) {
m->enable_wall_messages,
m->scheduled_shutdown_type);
- if (!isempty(m->wall_message))
+ if (t)
fprintf(f, "WALL_MESSAGE=%s\n", t);
r = fflush_and_check(f);