From 668509e317d8ad3b05afabe57e91b517771c1269 Mon Sep 17 00:00:00 2001 From: GermainZ Date: Thu, 1 Jul 2021 13:38:21 +0200 Subject: [PATCH] Fix potential memory corruption when reading bools As per `man sd_bus_message_read`, boolean items should be read into an int rather than a bool as the latter can cause memory corruption. --- src/screencast/screencast.c | 4 ++-- src/screenshot/screenshot.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/screencast/screencast.c b/src/screencast/screencast.c index aa01b22..a6b09ce 100644 --- a/src/screencast/screencast.c +++ b/src/screencast/screencast.c @@ -267,9 +267,9 @@ static int method_screencast_select_sources(sd_bus_message *msg, void *data, } if (strcmp(key, "multiple") == 0) { - bool multiple; + int multiple; sd_bus_message_read(msg, "v", "b", &multiple); - logprint(INFO, "dbus: option multiple: %x", multiple); + logprint(INFO, "dbus: option multiple: %d", multiple); } else if (strcmp(key, "types") == 0) { uint32_t mask; sd_bus_message_read(msg, "v", "u", &mask); diff --git a/src/screenshot/screenshot.c b/src/screenshot/screenshot.c index 94c5f30..9df0ea7 100644 --- a/src/screenshot/screenshot.c +++ b/src/screenshot/screenshot.c @@ -83,14 +83,14 @@ static int method_screenshot(sd_bus_message *msg, void *data, } if (strcmp(key, "interactive") == 0) { - bool mode; + int mode; sd_bus_message_read(msg, "v", "b", &mode); - logprint(DEBUG, "dbus: option interactive: %x", mode); + logprint(DEBUG, "dbus: option interactive: %d", mode); interactive = mode; } else if (strcmp(key, "modal") == 0) { - bool modal; + int modal; sd_bus_message_read(msg, "v", "b", &modal); - logprint(DEBUG, "dbus: option modal: %x", modal); + logprint(DEBUG, "dbus: option modal: %d", modal); } else { logprint(WARN, "dbus: unknown option %s", key); sd_bus_message_skip(msg, "v");