From 20fc5811192463188b7ffd09897f1e959783d7d1 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Sat, 21 May 2016 18:30:33 -0400 Subject: 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 --- src/run/run.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/run') diff --git a/src/run/run.c b/src/run/run.c index 1d0f74ad21..d6c9b6d37a 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -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"); -- cgit v1.2.3-54-g00ecf