From 9bcbce4201afada1c0ad8ada0cbfbbf58a52a6a7 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Tue, 22 Oct 2013 03:27:38 +0200 Subject: bus: avoid 'bool' storage when retrieving 'b' from the message Just use an unsigned int as a bool type to avoid issues in the public message reading API; sizeof(bool) == 1, but the code copies 4 bytes at the pointers destination. --- src/libsystemd-bus/bus-message.c | 2 +- src/libsystemd-bus/bus-util.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libsystemd-bus') diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c index 511bdf503e..cfc45a3f71 100644 --- a/src/libsystemd-bus/bus-message.c +++ b/src/libsystemd-bus/bus-message.c @@ -2741,7 +2741,7 @@ int sd_bus_message_read_basic(sd_bus_message *m, char type, void *p) { break; case SD_BUS_TYPE_BOOLEAN: - *(int*) p = !!*(uint32_t*) q; + *(unsigned*) p = !!*(uint32_t*) q; break; case SD_BUS_TYPE_INT16: diff --git a/src/libsystemd-bus/bus-util.c b/src/libsystemd-bus/bus-util.c index c72610466d..42374fe16c 100644 --- a/src/libsystemd-bus/bus-util.c +++ b/src/libsystemd-bus/bus-util.c @@ -148,7 +148,7 @@ int bus_verify_polkit( #ifdef ENABLE_POLKIT else { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; - bool authorized = false, challenge = false; + unsigned authorized = false, challenge = false; r = sd_bus_call_method( bus, @@ -267,7 +267,7 @@ int bus_verify_polkit_async( #ifdef ENABLE_POLKIT q = hashmap_remove(*registry, m); if (q) { - bool authorized, challenge; + unsigned authorized, challenge; /* This is the second invocation of this function, and * there's already a response from polkit, let's -- cgit v1.2.3-54-g00ecf