]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/dbus: revert oversimplification (#3309)
authorJonathan Boulle <jonathanboulle@gmail.com>
Fri, 20 May 2016 14:20:00 +0000 (16:20 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 20 May 2016 14:20:00 +0000 (16:20 +0200)
free_and_strdup handles NULL but not empty strings.

See also:
https://github.com/systemd/systemd/pull/3283#issuecomment-220603145
https://github.com/systemd/systemd/pull/3307

src/core/dbus-execute.c

index 888319593c541af77e00d9735ab3f29d723b199d..3be88ddf903f43ca73de9c05aeca1779556b8e68 100644 (file)
@@ -1454,9 +1454,10 @@ int bus_exec_context_set_transient_property(
                         return r;
 
                 if (mode != UNIT_CHECK) {
-                        r = free_and_strdup(&c->selinux_context, s);
-                        if (r < 0)
-                                return r;
+                        if (isempty(s))
+                                c->selinux_context = mfree(c->selinux_context);
+                        else if (free_and_strdup(&c->selinux_context, s) < 0)
+                                return -ENOMEM;
 
                         unit_write_drop_in_private_format(u, mode, name, "%s=%s\n", name, strempty(s));
                 }