]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dbus-execute: make transfer of CPUAffinity endian safe (#12711)
authorMichal Sekletar <msekletar@users.noreply.github.com>
Fri, 31 May 2019 13:23:23 +0000 (15:23 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 31 May 2019 13:23:23 +0000 (15:23 +0200)
We store the affinity mask in the native endian. However, over D-Bus we
must transfer the mask in little endian byte order.

This is the second part of c367f996f5f091a63f812f0140b304c649be77fc.

src/core/dbus-execute.c

index d7d339b9d792538b762236912f91cf2154c3c685..3a71e7bcde06ee14b0e4bdc2cc024a535871e6dd 100644 (file)
@@ -214,12 +214,15 @@ static int property_get_cpu_affinity(
                 sd_bus_error *error) {
 
         ExecContext *c = userdata;
+        _cleanup_free_ uint8_t *array = NULL;
+        size_t allocated;
 
         assert(bus);
         assert(reply);
         assert(c);
 
-        return sd_bus_message_append_array(reply, 'y', c->cpu_set.set, c->cpu_set.allocated);
+        (void) cpu_set_to_dbus(&c->cpu_set, &array, &allocated);
+        return sd_bus_message_append_array(reply, 'y', array, allocated);
 }
 
 static int property_get_timer_slack_nsec(