run: do not try to use reply after freeing it (#3318)
We'd call sd_bus_message_unref and then proceed to use variables pointing into the reply buffer (fd and char*). dup the fd and copy the string before destorying the reply. This makes systemd-run run again for me. https://bugzilla.redhat.com/show_bug.cgi?id=1337636
This commit is contained in:
+3
-4
@@ -760,6 +760,7 @@ static int start_transient_service(
|
||||
|
||||
} else if (arg_transport == BUS_TRANSPORT_MACHINE) {
|
||||
_cleanup_(sd_bus_unrefp) sd_bus *system_bus = NULL;
|
||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *pty_reply = NULL;
|
||||
const char *s;
|
||||
|
||||
r = sd_bus_default_system(&system_bus);
|
||||
@@ -772,19 +773,17 @@ static int start_transient_service(
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"OpenMachinePTY",
|
||||
&error,
|
||||
&reply,
|
||||
&pty_reply,
|
||||
"s", arg_host);
|
||||
if (r < 0) {
|
||||
log_error("Failed to get machine PTY: %s", bus_error_message(&error, -r));
|
||||
return r;
|
||||
}
|
||||
|
||||
r = sd_bus_message_read(reply, "hs", &master, &s);
|
||||
r = sd_bus_message_read(pty_reply, "hs", &master, &s);
|
||||
if (r < 0)
|
||||
return bus_log_parse_error(r);
|
||||
|
||||
reply = sd_bus_message_unref(reply);
|
||||
|
||||
master = fcntl(master, F_DUPFD_CLOEXEC, 3);
|
||||
if (master < 0)
|
||||
return log_error_errno(errno, "Failed to duplicate master fd: %m");
|
||||
|
||||
Reference in New Issue
Block a user