chiark / gitweb /
sd-bus: make sure bus_map_all_properties() handle booleans right
authorLennart Poettering <lennart@poettering.net>
Wed, 15 Jun 2016 20:41:56 +0000 (22:41 +0200)
committerSven Eden <yamakuzure@gmx.net>
Fri, 16 Jun 2017 08:13:01 +0000 (10:13 +0200)
sd-bus generally exposes bools as "int" instead of "bool" in the public API.
This is relevant when unmarshaling booleans, as the relevant functions expect
an int* pointer and no bool* pointer. Since sizeof(bool) is not necessarily the
same as sizeof(int) this is problematic and might result in memory corruption.

Let's fix this, and make sure bus_map_all_properties() handles booleans as
ints, as the rest of sd-bus, and make all users of it expect the right thing.

src/login/loginctl.c
src/shared/bus-util.c

index 7d71e2e1c737ec3f1b11a1d3c7cfc5a1862c6811..abc3cf38c91a731034b3296be752bfd468ce785b 100644 (file)
@@ -318,7 +318,7 @@ typedef struct SessionStatusInfo {
         char *seat;
         char *tty;
         char *display;
-        bool remote;
+        int remote;
         char *remote_host;
         char *remote_user;
         char *service;
@@ -332,7 +332,7 @@ typedef struct SessionStatusInfo {
 
 typedef struct UserStatusInfo {
         uid_t uid;
-        bool linger;
+        int linger;
         char *name;
         struct dual_timestamp timestamp;
         char *state;
index 12b091cebe446ca1e1b31f82c07bcbc26685db90..ebfe2255f441b83182e27757e6020baa70e78ddb 100644 (file)
@@ -1052,7 +1052,7 @@ static int map_basic(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_
 
         case SD_BUS_TYPE_BOOLEAN: {
                 unsigned b;
-                bool *p = userdata;
+                int *p = userdata;
 
                 r = sd_bus_message_read_basic(m, type, &b);
                 if (r < 0)