summaryrefslogtreecommitdiff
path: root/src/machine/machine-dbus.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-03-07 14:01:45 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-03-07 14:01:45 -0500
commit2c07315225bef6be4830bce25a74da7f0ba4fcdc (patch)
treea36819ffde64067d556ff1d26687f1426b628dbd /src/machine/machine-dbus.c
parentfadce6caf57986dc941e5fe3c860998890d49fd2 (diff)
machine: do not rely on asprintf setting arg on error
Strictly speaking, the output variable is undefined if asprintf fails. We use the return value not the arg everywhere, and should we do here.
Diffstat (limited to 'src/machine/machine-dbus.c')
-rw-r--r--src/machine/machine-dbus.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c
index 9e78a678ef..d6b8c90090 100644
--- a/src/machine/machine-dbus.c
+++ b/src/machine/machine-dbus.c
@@ -471,6 +471,7 @@ int bus_machine_method_open_login(sd_bus *bus, sd_bus_message *message, void *us
_cleanup_close_ int master = -1;
Machine *m = userdata;
const char *p;
+ char *address;
int r;
if (m->class != MACHINE_CONTAINER)
@@ -509,13 +510,14 @@ int bus_machine_method_open_login(sd_bus *bus, sd_bus_message *message, void *us
return r;
#ifdef ENABLE_KDBUS
- asprintf(&container_bus->address, "x-machine-kernel:pid=" PID_FMT ";x-machine-unix:pid=" PID_FMT, m->leader, m->leader);
+# define ADDRESS_FMT "x-machine-kernel:pid=%1$" PID_PRI ";x-machine-unix:pid=%1$" PID_PRI
#else
- asprintf(&container_bus->address, "x-machine-unix:pid=" PID_FMT, m->leader);
+# define ADDRESS_FMT "x-machine-unix:pid=%1$" PID_PRI
#endif
- if (!container_bus->address)
+ if (asprintf(&address, ADDRESS_FMT, m->leader) < 0)
return log_oom();
+ container_bus->address = address;
container_bus->bus_client = true;
container_bus->trusted = false;
container_bus->is_system = true;