summaryrefslogtreecommitdiff
path: root/src/systemctl
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-21 05:07:44 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-21 05:15:09 +0100
commit373d32c9f4746d58cda8c62f4c70d2e0e7aae1af (patch)
tree3022dc5c52f0328003a746c98a6b53aedfdf5ecd /src/systemctl
parente10a55fd72b5246cec1bbd09135d544db32e0414 (diff)
systemctl: fix bad memory access when processing PIDs on the "systemctl status" command line
Diffstat (limited to 'src/systemctl')
-rw-r--r--src/systemctl/systemctl.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index d1f68754a..d0a03d9f2 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -3678,6 +3678,7 @@ static int get_unit_dbus_path_by_pid(
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
+ char *u;
int r;
r = sd_bus_call_method(
@@ -3694,10 +3695,15 @@ static int get_unit_dbus_path_by_pid(
return r;
}
- r = sd_bus_message_read(reply, "o", unit);
+ r = sd_bus_message_read(reply, "o", &u);
if (r < 0)
return bus_log_parse_error(r);
+ u = strdup(u);
+ if (!u)
+ return log_oom();
+
+ *unit = u;
return 0;
}
@@ -3880,8 +3886,10 @@ static int show(sd_bus *bus, char **args) {
} else {
/* Interpret as PID */
r = get_unit_dbus_path_by_pid(bus, id, &unit);
- if (r < 0)
+ if (r < 0) {
ret = r;
+ continue;
+ }
}
show_one(args[0], bus, unit, show_properties, &new_line, &ellipsized);